Re: Introduce Index Aggregate - new GROUP BY strategy

From: Sergey Soloviev <sergey(dot)soloviev(at)tantorlabs(dot)ru>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Introduce Index Aggregate - new GROUP BY strategy
Date: 2025-12-10 14:22:01
Message-ID: 71b16ba8-c65a-4ef1-a197-2f7d39650101@tantorlabs.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi!

I have looked again at planner's code and found mistake in cost calculation:

1. There was an extra `LOG2(numGroups)` multipler that accounts height of
    btree index, but actually it is extra multiplier. Now cost is calculated as
    much like sort: input_tuples * (2.0 * cpu_operator_cost * numGroupCols).
2. IndexAgg requires spilling index on disk to save sort order, but code that
    calculates this cost used this value without HAVING quals adjustment.

After fixing these parts, more plans started to use Index Aggregate node.
New patches have this fixed.

Also, patches contains several minor fixes of compiler warnings to which I
did not pay attention during development, but CI pipeline complained about.

---
Sergey Soloviev

TantorLabs: https://tantorlabs.com

Attachment Content-Type Size
v2-0001-add-in-memory-btree-tuple-index.patch text/x-patch 23.6 KB
v2-0002-introduce-AGG_INDEX-grouping-strategy-node.patch text/x-patch 86.4 KB
v2-0003-make-use-of-IndexAggregate-in-planner-and-explain.patch text/x-patch 20.4 KB
v2-0004-fix-tests-for-IndexAggregate.patch text/x-patch 60.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Srirama Kucherlapati 2025-12-10 14:31:43 RE: AIX support
Previous Message Dagfinn Ilmari Mannsåker 2025-12-10 14:19:27 Re: Solaris versus our NLS files