Repository navigation
Properly return column stats from sub-queries with joins so that parent query can use them to join reordering - #99096
Merged
Merged
Conversation
Contributor
|
Workflow [PR], commit [6070702] Summary: ❌
|
Contributor
LLVM Coverage Report
PR changed lines: PR changed-lines coverage: 95.16% (118/124) |
davenger
force-pushed
the
fix_stats_from_join_steps
branch
from
March 10, 2026 11:17
ee88120 to
6070702
Compare
vdimir
approved these changes
Mar 12, 2026
Contributor
|
Hi @davenger @vdimir — while reviewing this PR I found the following:
Happy to discuss — close anything that's wrong or already addressed. |
1 task
1 task
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.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Properly return column stats from sub-queries with joins so that parent query can use them for join reordering.
Documentation entry for user-facing changes
Note
Medium Risk
Changes join-order optimization to carry and update per-column NDV statistics across joined subplans, which can alter chosen join orders/algorithms and impact performance characteristics.
Overview
Join-order optimization now propagates column statistics.
JoinStepLogicalstores and exposesresult_column_stats, andoptimizeJoinreturns these stats when an optimized logical join is used as an input to higher-level planning.DP join enumeration carries NDVs through join trees.
DPJoinEntrynow trackscolumn_stats, merges child stats when building join nodes, normalizes NDVs for equi-join keys, and caps NDVs by estimated output rows; selectivity estimation for multi-relation components now consults these propagated stats.Subquery joins are optimized for stats even when not flattened into the query graph.
addChildQueryGraphadditionally optimizes nestedJoinStepLogicalnodes hidden under single-child wrappers to ensure their stats feed parent join reordering, with updated/added stateless tests covering the new behavior.Written by Cursor Bugbot for commit 6070702. This will update automatically on new commits. Configure here.
Version info
26.3.1.622