Re: Optimize WindowAgg's use of tuplestores

Поиск
Список
Период
Сортировка
От David Rowley
Тема Re: Optimize WindowAgg's use of tuplestores
Дата
Msg-id CAApHDvqbHxpiExo-krM7H+5NNL41QXdWp7ekzwgJk7Y8ff5gcQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Optimize WindowAgg's use of tuplestores  (Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>)
Ответы Re: Optimize WindowAgg's use of tuplestores
Re: Optimize WindowAgg's use of tuplestores
Re: Optimize WindowAgg's use of tuplestores
Список pgsql-hackers
On Wed, 10 Jul 2024 at 02:42, Ashutosh Bapat
<ashutosh.bapat.oss@gmail.com> wrote:
> Observations
> 1. The numbers corresponding to 10 and 100 partitions are higher when
> patched. That might be just noise. I don't see any reason why it would
> impact negatively when there are a small number of partitions. The
> lower partition cases also have a higher number of rows per partition,
> so is the difference between MemoryContextDelete() vs
> MemoryContextReset() making any difference here. May be worth
> verifying those cases carefully. Otherwise upto 1000 partitions, it
> doesn't show any differences.

I think this might just be noise as a result of rearranging code. In
terms of C code, I don't see any reason for it to be slower.  If you
look at GenerationDelete() (as what is getting called from
MemoryContextDelete()), it just calls GenerationReset(). So resetting
is going to always be less work than deleting the context, especially
given we don't need to create the context again when we reset it.

I wrote the attached script to see if I can also see the slowdown and
I do see the patched code come out slightly slower (within noise
levels) in lower partition counts.

To get my compiler to produce code in a more optimal order for the
common case, I added unlikely() to the "if (winstate->all_first)"
condition.  This is only evaluated on the first time after a rescan,
so putting that code at the end of the function makes more sense.  The
attached v2 patch has it this way.  You can see the numbers look
slightly better in the attached graph.

Thanks for having a look at this.

David

Вложения

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

Предыдущее
От: Rafia Sabih
Дата:
Сообщение: Re: Things I don't like about \du's "Attributes" column
Следующее
От: Justin Pryzby
Дата:
Сообщение: Re: CREATE INDEX CONCURRENTLY on partitioned index