-
Notifications
You must be signed in to change notification settings - Fork 3.9k
opt: fix functional deps and stats for WithScanExpr #40523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status:
complete! 1 of 0 LGTMs obtained (waiting on @justinj, @RaduBerinde, and @rytaft)
pkg/sql/opt/memo/statistics_builder.go, line 2112 at r1 (raw file):
inColSet := translateColSet(colSet, withScan.OutCols, withScan.InCols) // TODO(rytaft): Is there an easy way to access the WithExpr itself?
This was how it worked originally, but it was problematic because the WithExpr can change out from underneath the WithScan (via, say, the replacement of placeholders). I forget exactly why this caused problems but it made a lot of things difficult.
pkg/sql/opt/memo/statistics_builder.go, line 2112 at r1 (raw file): Previously, justinj (Justin Jaffray) wrote…
But wouldn't we want to re-optimize the full tree if things change in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status:
complete! 1 of 0 LGTMs obtained (waiting on @RaduBerinde and @rytaft)
pkg/sql/opt/memo/statistics_builder.go, line 2112 at r1 (raw file):
Previously, rytaft (Rebecca Taft) wrote…
But wouldn't we want to re-optimize the full tree if things change in the
WithExpr
? Like if we learn after placeholder replacement that the size of theWithExpr
is much smaller than originally thought?
We don't have any precedent for re-optimizing expressions that haven't themselves changed, do we? We'd have to add in an extra mechanism that walks and re-interns (or something) WithScanExpr
s that reference WithExpr
s that have changed? Sounds doable but a little tricky, and like it might invalidate a handful of assumptions
This commit fixes the functional dependencies and stats calculation for WithScanExpr so they use the output columns rather than the input columns. Fixes cockroachdb#40296 Release note: None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TFTR!
I had to add a buildWithScan
function to the statisticsBuilder
since the shallow copy of stats from the BindingProps
was causing some nasty memory overwriting issues. PTAL.
Reviewable status:
complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @justinj and @RaduBerinde)
pkg/sql/opt/memo/statistics_builder.go, line 2112 at r1 (raw file):
Previously, justinj (Justin Jaffray) wrote…
We don't have any precedent for re-optimizing expressions that haven't themselves changed, do we? We'd have to add in an extra mechanism that walks and re-interns (or something)
WithScanExpr
s that referenceWithExpr
s that have changed? Sounds doable but a little tricky, and like it might invalidate a handful of assumptions
Yea, good point. Seems like it might be worth doing in the future, but not for 19.2. I rephrased this TODO a bit so we can come back to it later.
@justinj ok to merge with the latest changes? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status:
complete! 1 of 0 LGTMs obtained (waiting on @justinj and @RaduBerinde)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TFTR!
bors r+
Reviewable status:
complete! 1 of 0 LGTMs obtained (waiting on @justinj and @RaduBerinde)
40523: opt: fix functional deps and stats for WithScanExpr r=rytaft a=rytaft This commit fixes the functional dependencies and stats calculation for `WithScanExpr` so they use the output columns rather than the input columns. Fixes #40296 Release note: None 40601: sql: fix wrong representation of SHOW JOBS r=spaskob a=spaskob `WHEN COMPLETE` was wrongly being put in the end of the string representation of `SHOW JOBS WHEN COMPLETE SELECT...` stmt. Fixes: #40534. Release note (bug fix): None Co-authored-by: Rebecca Taft <[email protected]> Co-authored-by: Spas Bojanov <[email protected]>
Build succeeded |
This commit fixes the functional dependencies and stats calculation
for
WithScanExpr
so they use the output columns rather than the inputcolumns.
Fixes #40296
Release note: None