Hi hackers,

In each PathKey we have an EC representing the value being sorted on.
This works correctly and efficiently in scan/join planning since the
members in an EC are always equal to each other.

However, after applying GROUP BY grouping sets, the members in an EC may
not be that equivalent any more, because NULLS may be emitted by
grouping sets. As a result, we may lose some sort keys incorrectly.

# explain (costs off) select a, b from foo where a = b group by cube(a, b)
order by a, b;
          QUERY PLAN
-------------------------------
 Sort
   Sort Key: a
   ->  MixedAggregate
         Hash Key: a, b
         Hash Key: a
         Hash Key: b
         Group Key: ()
         ->  Seq Scan on foo
               Filter: (a = b)
(9 rows)

I believe we should not ignore sort key 'b' in the query above.

Is this a problem we should be worried about?

Thanks
Richard

Reply via email to