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-12 16:23:15
Message-ID: 345c715f-edb2-4903-9ae1-00d6ca7e92f1@tantorlabs.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi!

I have finally added support for Partial IndexAggregate. There was a problem with
sortgroupref and target list entries mismatch due to partial aggregates in it.
To solve this I had to add new argument to 'create_agg_path' - 'pathkeys' which is
a List of PathKey.

Previously this information was calculated in the function just like AGG_SORTED
do this. But when we calculating pathkeys we must consider whether it is a child
rel to properly build pathkeys and if so use it's parent. The latter information is
not known inside 'create_agg_path', thus instead of passing 'parent' we explicitly
pass already built 'pathkeys'. I did not change AGG_SORTED logic, so this  is used
only by AGG_INDEX.

This logic is placed in another patch file just to make review of this change easier.

Also, cost calculation logic is adjusted a bit - it takes into account top-down index
traversal and final external merge cost is added only if spill expected.

---
Sergey Soloviev
TantorLabs: https://tantorlabs.com

Attachment Content-Type Size
v3-0001-add-in-memory-btree-tuple-index.patch text/x-patch 23.6 KB
v3-0002-introduce-AGG_INDEX-grouping-strategy-node.patch text/x-patch 86.5 KB
v3-0003-make-use-of-IndexAggregate-in-planner-and-explain.patch text/x-patch 20.9 KB
v3-0004-add-support-for-Partial-IndexAggregate.patch text/x-patch 14.3 KB
v3-0005-fix-tests-for-IndexAggregate.patch text/x-patch 81.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2025-12-12 17:36:17 Re: pg_plan_advice
Previous Message Nathan Bossart 2025-12-12 16:23:14 Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments