cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
30.14k stars 3.81k forks source link

sql: should distribute large constrained scans #75178

Open RaduBerinde opened 2 years ago

RaduBerinde commented 2 years ago

We currently don't recommend distributing constrained scans, even if they are very large: https://github.com/cockroachdb/cockroach/blob/d990758125a1e323ff28cb8ea661f8d1a97ea2e7/pkg/sql/distsql_physical_planner.go#L536

I think we should distribute anything that has to scan a large amount of data. A sample case is in https://github.com/cockroachdb/cockroach/issues/74736#issuecomment-1016073783 (although the large number of spans in the constraint is problematic there).

CC @yuzefovich

Jira issue: CRDB-12497

github-actions[bot] commented 1 year ago

We have marked this issue as stale because it has been inactive for 18 months. If this issue is still relevant, removing the stale label or adding a comment will keep it active. Otherwise, we'll close it in 10 days to keep the issue queue tidy. Thank you for your contribution to CockroachDB!

michae2 commented 3 months ago

One workaround is to add an unnecessary ORDER BY to the query, which will switch to shouldDistribute: https://github.com/cockroachdb/cockroach/blob/1d74b00dd79850fa7c74db08793179260e965b5c/pkg/sql/distsql_physical_planner.go#L696