@@ -400,14 +400,13 @@ func (m *Memo) OptimizeRoot() error {
400400// the same subgroup dependencies. After finding the best implementation
401401// for a particular group, we fix the best plan for that group and recurse
402402// into its parents.
403- // TODO: we should not have to cost every plan, sometimes there is a provably
403+ // TODO: we should not have to cost every plan, sometimes there is a probably
404404// best case implementation
405405func (m * Memo ) optimizeMemoGroup (grp * ExprGroup ) error {
406406 if grp .Done {
407407 return nil
408408 }
409409
410- var err error
411410 n := grp .First
412411 if _ , ok := n .(SourceRel ); ok {
413412 // We should order the search bottom-up so that physical operators
@@ -425,7 +424,7 @@ func (m *Memo) optimizeMemoGroup(grp *ExprGroup) error {
425424 for n != nil {
426425 var cost float64
427426 for _ , g := range n .Children () {
428- err = m .optimizeMemoGroup (g )
427+ err : = m .optimizeMemoGroup (g )
429428 if err != nil {
430429 return err
431430 }
@@ -437,15 +436,13 @@ func (m *Memo) optimizeMemoGroup(grp *ExprGroup) error {
437436 }
438437
439438 if grp .RelProps .Distinct .IsHash () {
440- var dCost float64
441439 if sortedInputs (n ) {
442440 n .SetDistinct (SortedDistinctOp )
443441 } else {
444442 n .SetDistinct (HashDistinctOp )
445443 d := & Distinct {Child : grp }
446- dCost = float64 (statsForRel (m .Ctx , d ).RowCount ())
444+ relCost + = float64 (statsForRel (m .Ctx , d ).RowCount ())
447445 }
448- relCost += dCost
449446 } else {
450447 n .SetDistinct (NoDistinctOp )
451448 }
@@ -457,9 +454,6 @@ func (m *Memo) optimizeMemoGroup(grp *ExprGroup) error {
457454 }
458455
459456 grp .Done = true
460- if err != nil {
461- return err
462- }
463457 return nil
464458}
465459
0 commit comments