Skip to content

Planner now uses correct calculation for ordering of aggregate scans over permuted min/max indexes - #3333

Merged
alecgrieser merged 3 commits into
FoundationDB:mainfrom
alecgrieser:0331-fix-permuted-order-calculation
May 30, 2025
Merged

alecgrieser merged 3 commits into
FoundationDB:mainfrom
alecgrieser:0331-fix-permuted-order-calculation

Conversation

@alecgrieser

Copy link
Copy Markdown
Collaborator

The way the ordering key is generated for permuted min and max indexes requires that the planner handle the permutation of the min/max aggregate with zero or more grouping columns. We were not correctly handling that, which meant that we were crafting incorrect planner keys. This would lead to strange comparison keys with IN-union plans, and it could lead to ORDER BY constraints not being matched. This handles that appropriately, with some additional tests to make sure we are now considering more interesting examples of queries with min or max indexes and ordering constraints.

This fixes #3331.

…over permuted min/max indexes

The way the ordering key is generated for permuted min and max indexes requires that the planner handle the permutation of the min/max aggregate with zero or more grouping columns. We were not correctly handling that, which meant that we were crafting incorrect planner keys. This would lead to strange comparison keys with IN-union plans, and it could lead to `ORDER BY` constraints not being matched. This handles that appropriately, with some additional tests to make sure we are now considering more interesting examples of queries with min or max indexes and ordering constraints.

This fixes FoundationDB#3331.
@alecgrieser alecgrieser added the bug fix Change that fixes a bug label May 2, 2025

@hatyo hatyo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@alecgrieser
alecgrieser merged commit 5caafc5 into FoundationDB:main May 30, 2025
@alecgrieser
alecgrieser deleted the 0331-fix-permuted-order-calculation branch May 30, 2025 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug fix Change that fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect ordering key calculated for permuted min/max indexes

2 participants