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
29.94k stars 3.78k forks source link

opt: introduce limits to `Constraint.Combine` #112454

Open yuzefovich opened 11 months ago

yuzefovich commented 11 months ago

We have a customer who reported that certain queries are effectively stuck during planning. This is because Constraint.Combine can explore many thousands of combinations. It was partially addressed by fixing #111862, but we also should introduce some limits to amount of time (or combinations) we spend in that code path. This would improve planning time and can eliminate some OOMs too.

Jira issue: CRDB-32426

michae2 commented 11 months ago

[triage] One proposal was to limit the quadratic exploration based on time or memory or some limit. (Maybe something like join_reorder_limit?) Could also try pushing the cross join into execution time, by cross joining the spans.