Fix sort optimization on PostgreSQL 19 - #10262
Merged
Merged
Conversation
|
@melihmutlu, @kpan2034: please review this pull request.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
akuzm
approved these changes
Jul 15, 2026
akuzm
left a comment
Member
There was a problem hiding this comment.
Looking at the commit, I see it added check for windows_pathkeys as well, let's replace them too.
dbeck
approved these changes
Jul 15, 2026
The sort optimization lets an index provide the order requested by an ORDER BY on time_bucket, avoiding a separate sort. It works by swapping the query pathkeys for a simplified form while it builds index paths. PostgreSQL 19 stopped looking at the query pathkeys when it decides which index orderings are useful and looks at the sort pathkeys instead, so the swap had no effect and no ordered index path was built. Swap the sort pathkeys as well while building the paths. Upstream changes: Make truncate_useless_pathkeys() consider WindowFuncs. postgres/postgres@a5a68dd6d51
svenklemm
force-pushed
the
sven/pg19_sort_pathkeys
branch
from
July 15, 2026 09:03
5e1271d to
882c559
Compare
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 sort optimization lets an index provide the order requested by an
ORDER BY on time_bucket, avoiding a separate sort. It works by swapping
the query pathkeys for a simplified form while it builds index paths.
PostgreSQL 19 stopped looking at the query pathkeys when it decides which
index orderings are useful and looks at the sort pathkeys instead, so the
swap had no effect and no ordered index path was built. Swap the sort
pathkeys as well while building the paths.
Upstream changes:
Make truncate_useless_pathkeys() consider WindowFuncs.
postgres/postgres@a5a68dd6d51
Disable-check: force-changelog-file