-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
opt: add optimizer_min_row_count
session setting
#140065
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
e4d1a9d
to
da30cfe
Compare
Informs cockroachdb#64570 Informs cockroachdb#130201 Release note (sql change): The `optimizer_min_row_count` session setting has been added which sets a lower bound on row count estimates for relational expressions during query planning. A value of zero, which is the default, indicates no lower bound. Note that if this is set to a value greater than zero, a row count of zero can still be estimated for expressions with a cardinality of zero, e.g., for a contradictory filter. Setting this to a value higher than 0, such as 1, may yield better query plans in some cases, such as when statistics are frequently stale and inaccurate.
da30cfe
to
da6fbb5
Compare
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.
Great idea to make it configurable. This is nice!
Reviewed 25 of 25 files at r1, all commit messages.
Reviewable status:complete! 1 of 0 LGTMs obtained (waiting on @DrewKimball and @rytaft)
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.
Reviewed 25 of 25 files at r1, all commit messages.
Reviewable status:complete! 2 of 0 LGTMs obtained (waiting on @DrewKimball, @mgartner, and @rytaft)
pkg/sql/opt/memo/statistics_builder_test.go
line 115 at r1 (raw file):
relProps.NotNullCols = cs.ExtractNotNullCols(ctx, &evalCtx) s := relProps.Statistics() const minRowCount = 0
Worth re-running this test with minRowCount = 1?
pkg/sql/opt/memo/statistics_builder.go
line 842 at r1 (raw file):
func (sb *statisticsBuilder) buildScan(scan *ScanExpr, relProps *props.Relational) { s := relProps.Statistics() if zeroCardinality := s.Init(relProps, sb.minRowCount); zeroCardinality {
Boilerplate like this is great opportunity to refactor. If the Go designers thought highly enough of us to think we could use macros without hurting ourselves, this would be an excellent use, but we'll have to make do with passing function pointers around.
I know you're on deadline, so fine if you don't want to deal with this now.
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! 2 of 0 LGTMs obtained (waiting on @DrewKimball and @rytaft)
pkg/sql/opt/memo/statistics_builder_test.go
line 115 at r1 (raw file):
Previously, mw5h (Matt White) wrote…
Worth re-running this test with minRowCount = 1?
The coverage of this test is minimal, so I don't think we get much from this. I think the datadriven tests I added are sufficient.
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! 2 of 0 LGTMs obtained (waiting on @DrewKimball and @rytaft)
pkg/sql/opt/memo/statistics_builder.go
line 842 at r1 (raw file):
Previously, mw5h (Matt White) wrote…
Boilerplate like this is great opportunity to refactor. If the Go designers thought highly enough of us to think we could use macros without hurting ourselves, this would be an excellent use, but we'll have to make do with passing function pointers around.
I know you're on deadline, so fine if you don't want to deal with this now.
Talked in Slack - we'll keep as-is for now, but we can also consider refactoring this in the future!
TFTRs! bors r+ |
Encountered an error creating backports. Some common things that can go wrong:
You might need to create your backport manually using the backport tool. error creating merge commit from da6fbb5 to blathers/backport-release-24.1-140065: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict [] you may need to manually resolve merge conflicts with the backport tool. Backport to branch 24.1.x failed. See errors above. error creating merge commit from da6fbb5 to blathers/backport-release-24.2-140065: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict [] you may need to manually resolve merge conflicts with the backport tool. Backport to branch 24.2.x failed. See errors above. error creating merge commit from da6fbb5 to blathers/backport-release-24.3-140065: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict [] you may need to manually resolve merge conflicts with the backport tool. Backport to branch 24.3.x failed. See errors above. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
Informs #64570
Informs #130201
Release note (sql change): The
optimizer_min_row_count
session settinghas been added which sets a lower bound on row count estimates for
relational expressions during query planning. A value of zero, which is
the default, indicates no lower bound. Note that if this is set to a
value greater than zero, a row count of zero can still be estimated for
expressions with a cardinality of zero, e.g., for a contradictory
filter. Setting this to a value higher than 0, such as 1, may yield
better query plans in some cases, such as when statistics are frequently
stale and inaccurate.