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.18k stars 3.82k forks source link

opt: contradictions from check constraints should be used for optimization #63112

Open maryliag opened 3 years ago

maryliag commented 3 years ago

Currently, CHECK constraints are not being take into consideration for optimization, for example: create table users (age int, check (age > 0 and age < 150));

And then try to select with a value that is not possible, such as select * from users where age=200

Checking with the explain option, we can see that is doing a FULL SCAN, even though we won't find any values.

If the constraint is validated, it should be able to detect the contradiction and convert that scan to a zero values node.

Jira issue: CRDB-6430

github-actions[bot] commented 11 months 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!