Repository navigation
Keep sorting below PASTE JOIN in removeRedundantSorting - #128556
Conversation
PASTE JOIN matches rows by position, so ORDER BY in its inputs defines the result and is not redundant even under an order-independent aggregation or an outer ORDER BY. Check both JoinStepLogical and JoinStep for the PASTE kind, as filterPushDown already does.
|
Workflow [PR], commit [7f0f00c] Summary: ✅
AI ReviewSummaryPR #128556 preserves input sorting that determines row pairing in Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 18 s compile time in total, 7 of them have a recent master baseline. |
Backport #128556 to 26.10: Keep sorting below PASTE JOIN in removeRedundantSorting
Closes: #72693
Why
PASTE JOINpairs rows by position, so theORDER BYin its subqueries defines the result.removeRedundantSortingremoved those sorts when an order-independent aggregate or an outerORDER BYsat above the join.SELECT sum(a * b)overORDER BY a DESCpaste-joined withORDER BY breturns 30 instead of 10. Sorting below aPASTE JOINis now kept.What changed
checkPathFromCurrentSortingNodestops at aPASTE JOIN, in both the logical and the physical join step, asfilterPushDowndoes since Disable filter pushdown for PASTE JOIN #88078.Scope
PASTE JOIN. Other joins keep the optimization, and the test checks this with anINNER JOIN.Verification
ORDER BYand EXPLAIN cases.query_plan_remove_redundant_sorting = 0, and matches the arithmetic.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed wrong results of
PASTE JOINwhen theORDER BYin its subqueries was removed by thequery_plan_remove_redundant_sortingoptimization, for example under an aggregation or an outerORDER BY.Workflow [PR]
Sync PR [sync-upstream/pr/128556]
Version info
26.11.1.1155-master(included in26.11and later)