Re: Implementation of GROUPING SETS (T431: Extended grouping capabilities)
От | Hitoshi Harada |
---|---|
Тема | Re: Implementation of GROUPING SETS (T431: Extended grouping capabilities) |
Дата | |
Msg-id | e08cc0400908131049s15495fc5y42e0d102a0ae77c2@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Implementation of GROUPING SETS (T431: Extended grouping capabilities) (Pavel Stehule <pavel.stehule@gmail.com>) |
Ответы |
Re: Implementation of GROUPING SETS (T431: Extended
grouping capabilities)
|
Список | pgsql-hackers |
2009/8/14 Pavel Stehule <pavel.stehule@gmail.com>: > I prefered using CTE, because this way was the most short to small > bugs less prototype - with full functionality. You could make it by query rewriting, but as you say the best cleanest way is total refactoring of existing nodeAgg. How easy to implement is not convincing. >> When we want GROUPING SET(a, b), at first we sort by a and aggregate >> then sort by b and aggregate. This is the same as: >> >> select a, null, count(*) from x group by a >> union all >> select null, b, count(*) from x group by b >> >> so nothing better than query rewriting unless we invent something new. >> > the problem is when x is subquery. Then is better using CTE, because > we don't need repeat x evaluation twice. The most typical use case is, > so x isn't table. So we need single scan aggregate as far as possible. Buffering subquery's result is possible without CTE node. Tuplestore has that functionality but I found the buffered result will be sorted multiple times, one way might be to allow tuplesort to perform sort multiple times with different keys. Regards, -- Hitoshi Harada
В списке pgsql-hackers по дате отправления: