Skip to content

Conversation

@michae2
Copy link
Collaborator

@michae2 michae2 commented Dec 23, 2025

sql: add distsql_prevent_partitioning_soft_limited_scans

Add a setting to the physical planner which prevents partitioning of soft-limited scans, to make them match hard-limited scans. This makes them lazier.

Fixes: #160530

Release note (performance improvement): Add a new session variable, distsql_prevent_partitioning_soft_limited_scans, which, when true, prevents scans with soft limits from being planned as multiple TableReaders by the physical planner. This should decrease the initial setup costs of some fully-distributed query plans.


sql: enable distsql_prevent_partitioning_soft_limited_scans by default

Release note (performance improvement): enable setting distsql_prevent_partitioning_soft_limited_scans by default.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@michae2 michae2 force-pushed the soft_limit_scan branch 2 times, most recently from 253afed to f0d8984 Compare December 25, 2025 06:28
@michae2 michae2 mentioned this pull request Jan 5, 2026
@michae2 michae2 changed the title wip sql: add prevent_partitioning_soft_limit_table_readers Jan 6, 2026
@michae2 michae2 marked this pull request as ready for review January 6, 2026 08:41
@michae2 michae2 requested a review from a team as a code owner January 6, 2026 08:41
@michae2 michae2 requested review from a team, mw5h and yuzefovich and removed request for a team January 6, 2026 08:41
Copy link
Member

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix! :lgtm:

I could see us backporting both commits to 26.1. It's an innovation release after all, so it might be more stable to tweak the default in 26.1 as opposed to 26.2. Thoughts?

@yuzefovich reviewed 13 files and all commit messages, and made 2 comments.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @michae2 and @mw5h).


pkg/sql/vars.go line 4533 at r1 (raw file):

	// CockroachDB extension.
	`prevent_partitioning_soft_limit_table_readers`: {

nit: I think the session var should have distsql_ prefix. How about something like distsql_soft_limit_single_table_reader_enabled?

@cockroachdb cockroachdb deleted a comment from blathers-crl bot Jan 6, 2026
Add a setting to the physical planner which prevents partitioning of
soft-limited scans, to make them match hard-limited scans. This makes
them lazier.

Fixes: cockroachdb#160530

Release note (performance improvement): Add a new session variable,
`distsql_prevent_partitioning_soft_limited_scans`, which, when true,
prevents scans with soft limits from being planned as multiple
TableReaders by the physical planner. This should decrease the initial
setup costs of some fully-distributed query plans.
Release note (performance improvement): enable setting
`distsql_prevent_partitioning_soft_limited_scans` by default.
@michae2 michae2 changed the title sql: add prevent_partitioning_soft_limit_table_readers sql: add distsql_prevent_partitioning_soft_limited_scans Jan 7, 2026
@michae2 michae2 added backport-25.2.x Flags PRs that need to be backported to 25.2 backport-25.3.x Flags PRs that need to be backported to 25.3 backport-25.4.x Flags PRs that need to be backported to 25.4 backport-26.1.x Flags PRs that need to be backported to 26.1 backport-25.2.11-rc FROZEN: requires ER request to thaw backport-25.3.7-rc FROZEN: requires ER request to thaw backport-25.4.3-rc FROZEN: requires ER request to thaw labels Jan 7, 2026
Copy link
Collaborator Author

@michae2 michae2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TFTR! For now I'm only planning to backport the first commit.

bors r=yuzefovich

@michae2 made 2 comments.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @mw5h and @yuzefovich).


pkg/sql/vars.go line 4533 at r1 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

nit: I think the session var should have distsql_ prefix. How about something like distsql_soft_limit_single_table_reader_enabled?

I went with distsql_prevent_partitioning_soft_limited_scans, hope you don't mind it too much.

@craig
Copy link
Contributor

craig bot commented Jan 7, 2026

@craig craig bot merged commit e654896 into cockroachdb:master Jan 7, 2026
27 of 28 checks passed
@blathers-crl
Copy link

blathers-crl bot commented Jan 7, 2026

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 #160530: branch-release-25.2, branch-release-25.2.11-rc, branch-release-25.3, branch-release-25.3.7-rc, branch-release-25.4, branch-release-25.4.3-rc, branch-release-26.1.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@blathers-crl
Copy link

blathers-crl bot commented Jan 7, 2026

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

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.

error creating merge commit from 57ed28d to blathers/backport-release-25.2-160051: 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 25.2.x failed. See errors above.


💡 Consider backporting to the fork repo instead of the main repo. See instructions for more details.

error creating merge commit from 57ed28d to blathers/backport-release-25.3-160051: 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 25.3.x failed. See errors above.


💡 Consider backporting to the fork repo instead of the main repo. See instructions for more details.

error creating merge commit from 57ed28d to blathers/backport-release-25.4-160051: 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 25.4.x failed. See errors above.


💡 Consider backporting to the fork repo instead of the main repo. See instructions for more details.

💡 Consider backporting to the fork repo instead of the main repo. See instructions for more details.

error creating merge commit from 57ed28d to blathers/backport-release-25.2.11-rc-160051: 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 25.2.11-rc failed. See errors above.


💡 Consider backporting to the fork repo instead of the main repo. See instructions for more details.

error creating merge commit from 57ed28d to blathers/backport-release-25.3.7-rc-160051: 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 25.3.7-rc failed. See errors above.


💡 Consider backporting to the fork repo instead of the main repo. See instructions for more details.

error creating merge commit from 57ed28d to blathers/backport-release-25.4.3-rc-160051: 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 25.4.3-rc failed. See errors above.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@yuzefovich
Copy link
Member

Sounds good to me! I also have fragmented sleep right now, so I'll help with creating the RC backports 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-25.2.x Flags PRs that need to be backported to 25.2 backport-25.2.11-rc FROZEN: requires ER request to thaw backport-25.3.x Flags PRs that need to be backported to 25.3 backport-25.3.7-rc FROZEN: requires ER request to thaw backport-25.4.x Flags PRs that need to be backported to 25.4 backport-25.4.3-rc FROZEN: requires ER request to thaw backport-26.1.x Flags PRs that need to be backported to 26.1 backport-failed target-release-26.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sql: over-eager initial read of distributed soft-limited scan

3 participants