opt: add optimizer_span_limit and use in GenerateConstrainedScans#167180
opt: add optimizer_span_limit and use in GenerateConstrainedScans#167180trunk-io[bot] merged 2 commits intocockroachdb:masterfrom
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
|
😎 Merged successfully - details. |
e1e40df to
12490b3
Compare
This comment was marked as resolved.
This comment was marked as resolved.
1 similar comment
This comment was marked as resolved.
This comment was marked as resolved.
12490b3 to
c40d9da
Compare
This comment was marked as resolved.
This comment was marked as resolved.
1 similar comment
This comment was marked as resolved.
This comment was marked as resolved.
c40d9da to
3715752
Compare
This comment was marked as resolved.
This comment was marked as resolved.
1 similar comment
This comment was marked as resolved.
This comment was marked as resolved.
3715752 to
b9754ea
Compare
This comment was marked as resolved.
This comment was marked as resolved.
1 similar comment
This comment was marked as resolved.
This comment was marked as resolved.
22fe585 to
be22817
Compare
This comment was marked as resolved.
This comment was marked as resolved.
1 similar comment
This comment was marked as resolved.
This comment was marked as resolved.
be22817 to
317e881
Compare
This comment was marked as resolved.
This comment was marked as resolved.
317e881 to
ea695fb
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This commit creates a new session variable `optimizer_span_limit`, and uses it to bound the number of spans in constrained scans produced by `GenerateConstrainedScans`. Fixes: cockroachdb#167620 Release note: Add a new session variable `optimizer_span_limit` which bounds the number of spans the optimizer will allow in a single constrained index scan. If a single IN set has more items than this limit, that IN set will not be used to build a constrained index scan. If the cross product of two or more IN sets would produce more spans than this limit for a composite index, then only a prefix of the IN sets will be used to produce spans. For example, for the following table and query, only the predicates on columns `a` and `b` will be used to construct the constrained scan of `abc_idx`, because including the predicate on column `c` would produce more spans than `optimizer_span_limit`: ```sql CREATE TABLE abc (a INT, b INT, c INT, INDEX abc_idx (a, b, c)); SET optimizer_span_limit = 10; SELECT * FROM abc WHERE a IN (1, 3, 5) AND b IN (2, 4, 6) AND c IN (7, 9, 11); ``` Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
Set the default value of the `optimizer_span_limit` session variable to 2^17 (131072) instead of 0 (no limit). This provides a reasonable upper bound on the number of spans the optimizer will produce, preventing pathological cases where large cross-products of IN sets produce excessive spans. Informs: cockroachdb#167620 Release note (sql change): The session variable `optimizer_span_limit` now defaults to 131072. This bounds the number of spans the optimizer will allow in constrained index scans generated during query optimization. Queries that would exceed this limit will use fewer looser spans with remaining filters instead. Set to 0 to disable the limit. Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
ea695fb to
9887a57
Compare
This comment was marked as resolved.
This comment was marked as resolved.
|
I'm just looking to backport the first commit. |
DrewKimball
left a comment
There was a problem hiding this comment.
@DrewKimball reviewed 23 files and all commit messages, and made 1 comment.
Reviewable status:complete! 1 of 0 LGTMs obtained (waiting on mw5h).
|
You're welcome! TFTR! /trunk merge |
|
Based on the specified backports for this PR, I applied new labels to the following linked issue(s). Please adjust the labels as needed to match the branches actually affected by the issue(s), including adding any known older branches. Issue #167620: branch-release-25.4, branch-release-26.1, branch-release-26.2. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
|
Encountered an error creating backports. Some common things that can go wrong:
You might need to create your backport manually using the backport tool. 💡 Consider backporting to the fork repo instead of the main repo. See instructions for more details. merge conflict cherry-picking 52376f6 to blathers/backport-release-25.4-167180 Backport to branch 25.4.x failed. See errors above. 💡 Consider backporting to the fork repo instead of the main repo. See instructions for more details. merge conflict cherry-picking 52376f6 to blathers/backport-release-26.1-167180 Backport to branch 26.1.x failed. See errors above. 💡 Consider backporting to the fork repo instead of the main repo. See instructions for more details. merge conflict cherry-picking 52376f6 to blathers/backport-release-26.2-167180 Backport to branch 26.2.x failed. See errors above. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
|
blathers auth-check |
|
You shall pass |
opt: add optimizer_span_limit and use in GenerateConstrainedScans
This commit creates a new session variable
optimizer_span_limit, anduses it to bound the number of spans in constrained scans produced by
GenerateConstrainedScans.Fixes: #167620
Release note: Add a new session variable
optimizer_span_limitwhichbounds the number of spans the optimizer will allow in a single
constrained index scan. If a single IN set has more items than this
limit, that IN set will not be used to build a constrained index
scan. If the cross product of two or more IN sets would produce more
spans than this limit for a composite index, then only a prefix of the
IN sets will be used to produce spans.
For example, for the following table and query, only the predicates on
columns
aandbwill be used to construct the constrained scan ofabc_idx, because including the predicate on columncwould producemore spans than
optimizer_span_limit:Co-Authored-By: roachdev-claude roachdev-claude-bot@cockroachlabs.com
opt: set default optimizer_span_limit to 131072
Set the default value of the
optimizer_span_limitsession variable to2^17 (131072) instead of 0 (no limit). This provides a reasonable upper
bound on the number of spans the optimizer will produce, preventing
pathological cases where large cross-products of IN sets produce
excessive spans.
Informs: #167620
Release note (sql change): The session variable
optimizer_span_limitnow defaults to 131072. This bounds the number of spans the optimizer
will allow in constrained index scans generated during query
optimization. Queries that would exceed this limit will use fewer looser
spans with remaining filters instead. Set to 0 to disable the limit.
Co-Authored-By: roachdev-claude roachdev-claude-bot@cockroachlabs.com