Skip columnar index scan for GROUPING SETS / ROLLUP / CUBE - #9830
Merged
Conversation
|
@pnthao, @Poroma-Banerjee: please review this pull request.
|
svenklemm
force-pushed
the
sven/cis_grouping_sets
branch
from
May 16, 2026 11:33
2d18b61 to
1dc630f
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
svenklemm
force-pushed
the
sven/cis_grouping_sets
branch
from
May 16, 2026 15:12
1a6716b to
06d10ed
Compare
akuzm
reviewed
May 18, 2026
akuzm
approved these changes
May 18, 2026
antekresic
approved these changes
May 18, 2026
svenklemm
force-pushed
the
sven/cis_grouping_sets
branch
from
May 18, 2026 12:06
06d10ed to
9a2056d
Compare
svenklemm
enabled auto-merge (rebase)
May 18, 2026 12:08
svenklemm
force-pushed
the
sven/cis_grouping_sets
branch
from
May 18, 2026 12:11
9a2056d to
a582c40
Compare
The Agg rewrite in columnar index scan only updates the main Agg's targetlist and grpColIdx. Plans built for GROUPING SETS, ROLLUP and CUBE attach a chain of additional Aggs that share the same input, so those Aggs would keep pointing at the pre-rewrite column layout. Bail out before rewriting when the Agg has a non-empty grouping sets list or chain.
Cover query shapes that were missing from the test suite: - DISTINCT on a segmentby column (Agg without Aggrefs) - count(*) without GROUP BY - aggregate only in HAVING (not in SELECT) - GROUP BY ordinal position - GROUP BY () empty grouping - aggregate wrapped in COALESCE - aggregate above a JOIN - ordered-set aggregate (percentile_cont) - bool_and / bool_or - partition-wise aggregate - Aggref inside a SubLink in the outer tlist (inner aggregate belongs to a separate Agg and must not be touched by the outer rewrite) - HAVING with non-pushable expression on grouping columns (qual stays with the Agg instead of being pushed to the scan) - same Aggref node referenced from multiple tlist positions - GROUP BY column not in SELECT (appears only as resjunk in Agg tlist) - WHERE mixing segmentby and non-segmentby columns - HAVING NOT (Aggref ...) and HAVING Aggref IS NULL (mutator must recurse through BoolExpr and NullTest) - GROUP BY with explicit collation (grouping expression is a CollateExpr, not a bare Var) - self-join on the same hypertable (Agg sits over a Join, not over a ColumnarScan)
svenklemm
force-pushed
the
sven/cis_grouping_sets
branch
from
May 18, 2026 12:19
a582c40 to
4f836d4
Compare
Merged
surister
pushed a commit
that referenced
this pull request
May 19, 2026
# TimescaleDB Changelog **Please note: When updating your database, you should connect using This page lists all the latest features and updates to TimescaleDB. When you use psql to update your database, use the -X flag and prevent any .psqlrc commands from accidentally triggering the load of a previous DB version.** ## 2.27.1 (2026-05-19) This release contains performance improvements and bug fixes since the 2.27.0 release. We recommend that you upgrade at the next available opportunity. **Bugfixes** * [#9795](#9795) Delete orphaned `compression_settings` before migrating catalog table * [#9799](#9799) Fix `job_errors` view leaking failed jobs to non-owners * [#9800](#9800) Check hypertable ownership before recompression * [#9801](#9801) Fix information leak in `policy_reorder_remove` * [#9824](#9824) Adding migration scripts for composite bloom filters * [#9828](#9828) Skip columnar index scan when grouping by an expression * [#9830](#9830) Skip `ColumnarIndexScan` for GROUPING SETS / ROLLUP / CUBE **Thanks** * @homanp for reporting an information leak with the job_errors view
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Agg rewrite in columnar index scan only updates the main Agg's
targetlist and grpColIdx. Plans built for GROUPING SETS, ROLLUP and
CUBE attach a chain of additional Aggs that share the same input, so
those Aggs would keep pointing at the pre-rewrite column layout. Bail
out before rewriting when the Agg has a non-empty grouping sets list
or chain.
Disable-check: commit-count