Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
maryliag opened this issue Apr 5, 2021 · 1 comment
Open
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-queries SQL Queries Team
Projects

Comments

@maryliag
Copy link
Contributor

maryliag commented Apr 5, 2021

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

@maryliag maryliag added the C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) label Apr 5, 2021
@maryliag maryliag added this to Triage in SQL Queries via automation Apr 5, 2021
@mgartner mgartner moved this from Triage to 21.2 Milestone A in SQL Queries Apr 6, 2021
@RaduBerinde RaduBerinde added this to Triage in BACKLOG, NO NEW ISSUES: SQL Optimizer via automation Apr 6, 2021
@mgartner mgartner moved this from 21.2 Milestone A to Backlog in SQL Queries Apr 6, 2021
@RaduBerinde RaduBerinde moved this from Triage to Plan enhancements (lower priority) in BACKLOG, NO NEW ISSUES: SQL Optimizer Apr 6, 2021
@jlinder jlinder added the T-sql-queries SQL Queries Team label Jun 16, 2021
@mgartner mgartner changed the title SQL Queries: Consider CHECK constraint on optimization opt: contradictions from check constraints should be used for optimization Jun 22, 2022
@mgartner mgartner removed this from Plan enhancements (lower priority) in BACKLOG, NO NEW ISSUES: SQL Optimizer Jun 22, 2022
@mgartner mgartner moved this from Backlog to New Backlog in SQL Queries Feb 16, 2023
Copy link

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!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 25, 2023
@yuzefovich yuzefovich reopened this May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-queries SQL Queries Team
Projects
Archived in project
SQL Queries
New Backlog
Development

No branches or pull requests

3 participants