chore(engine): Eliminate unnecessary SortMerge node from physical plan (#19236)

This PR avoid creating the SortMerge node from the logical.Sort. This node was a no-op and only passed down the sort direction to its children.

Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
pull/19238/head
Christian Haudum 4 months ago committed by GitHub
parent 3700dc5395
commit 35816aa16f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 20
      pkg/engine/planner/physical/planner.go

@ -270,30 +270,14 @@ func (p *Planner) processSelect(lp *logical.Select, ctx *Context) ([]Node, error
return []Node{node}, nil
}
// Convert [logical.Sort] into one [SortMerge] node.
// Pass sort direction from [logical.Sort] to the children.
func (p *Planner) processSort(lp *logical.Sort, ctx *Context) ([]Node, error) {
order := DESC
if lp.Ascending {
order = ASC
}
node := &SortMerge{
Column: &ColumnExpr{Ref: lp.Column.Ref},
Order: order,
}
p.plan.addNode(node)
children, err := p.process(lp.Table, ctx.WithDirection(order))
if err != nil {
return nil, err
}
for i := range children {
if err := p.plan.addEdge(Edge{Parent: node, Child: children[i]}); err != nil {
return nil, err
}
}
return []Node{node}, nil
return p.process(lp.Table, ctx.WithDirection(order))
}
// Convert [logical.Limit] into one [Limit] node.

Loading…
Cancel
Save