Re: possible optimization: push down aggregates

Поиск
Список
Период
Сортировка
От Tomas Vondra
Тема Re: possible optimization: push down aggregates
Дата
Msg-id e8063776a8278cba845957f9a95132b9.squirrel@sq.gransy.com
обсуждение исходный текст
Ответ на Re: possible optimization: push down aggregates  (Merlin Moncure <mmoncure@gmail.com>)
Список pgsql-hackers
On 27 Srpen 2014, 21:41, Merlin Moncure wrote:
> On Wed, Aug 27, 2014 at 2:07 PM, Pavel Stehule <pavel.stehule@gmail.com>
>>
>> Are there some plans to use partitioning for aggregation?
>
> Besides min/max, what other aggregates (mean/stddev come to mind)
> would you optimize and how would you determine which ones could be?
> Where is that decision made?
>
> For example, could user defined aggregates be pushed down if you had a
> reaggregation routine broken out from the main one?

I think that what Pavel suggests is that when you are aggregating by
   GROUP BY x

and 'x' happens to be used for partitioning (making it impossible to
groups from different partitions to overlap), then it's perfectly fine to
perform the aggregation per partition, and just append the results.

If you need sorted output, you can sort the results (assuming the
cardinality of the output is much lower than the actual data).

This "append first, then aggregate" may be the cause for switch to sort
(because of fear that the amount of group will exceed work_mem), while we
could just as fine process each partition by hash aggregate separately.

Tomas




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

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: delta relations in AFTER triggers
Следующее
От: Merlin Moncure
Дата:
Сообщение: Re: possible optimization: push down aggregates