Re: Introduce Index Aggregate - new GROUP BY strategy
Sergey Soloviev <sergey.soloviev@tantorlabs.ru>
From: Sergey Soloviev <sergey.soloviev@tantorlabs.ru>
To: pgsql-hackers@lists.postgresql.org
Date: 2025-12-12T16:23:15Z
Lists: pgsql-hackers
Attachments
- v3-0001-add-in-memory-btree-tuple-index.patch (text/x-patch) patch v3-0001
- v3-0002-introduce-AGG_INDEX-grouping-strategy-node.patch (text/x-patch) patch v3-0002
- v3-0003-make-use-of-IndexAggregate-in-planner-and-explain.patch (text/x-patch) patch v3-0003
- v3-0004-add-support-for-Partial-IndexAggregate.patch (text/x-patch) patch v3-0004
- v3-0005-fix-tests-for-IndexAggregate.patch (text/x-patch) patch v3-0005
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