Sort keys are omitted incorrectly after grouping sets

Поиск
Список
Период
Сортировка
От Richard Guo
Тема Sort keys are omitted incorrectly after grouping sets
Дата
Msg-id CAMbWs48AtQTQGk37MSyDk_EAgDO3Y0iA_LzvuvGQ2uO_Wh2muw@mail.gmail.com
обсуждение исходный текст
Ответы Re: Sort keys are omitted incorrectly after grouping sets  (Greg Stark <stark@mit.edu>)
Список pgsql-hackers
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

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Masahiko Sawada
Дата:
Сообщение: Remove unused 'len' from pg_stat_recv_* functions
Следующее
От: Soumyadeep Chakraborty
Дата:
Сообщение: Changes to recovery_min_apply_delay are ignored while waiting for delay