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

Use ranges when dealing with suitable comparison operators #467

Open
asdine opened this issue Jul 2, 2022 · 0 comments
Open

Use ranges when dealing with suitable comparison operators #467

asdine opened this issue Jul 2, 2022 · 0 comments
Labels
Milestone

Comments

@asdine
Copy link
Collaborator

asdine commented Jul 2, 2022

Given the following table:

CREATE TABLE foo (a INT PRIMARY KEY);
genji> explain select * from foo where a > 10 AND a < 100;
{
  "plan": "table.Scan(\"foo\", [{\"min\": [10], \"exclusive\": true}]) | docs.Filter(a < 100)"
}

genji> explain select * from foo where a > 10 AND a < 120 OR a > 4 AND a < 100;
{
  "plan": "seqScan(foo) | filter(a > 10 AND a < 120 OR a > 4 AND a < 100)"
}

This should use ranges instead:

genji> explain select * from foo where a > 10 AND a < 100;
{
  "plan": "table.Scan(\"foo\", [{\"min\": [10], \"max\": [100], \"exclusive\": true}])"
}

genji> explain select * from foo where a > 10 AND a <100 OR a > 400 AND a < 1000;
{
   "plan": "table.Scan(\"foo\", [{\"min\": [4], \"max\": [120], \"exclusive\": true}, {\"min\": [400], \"max\": [1000], \"exclusive\": true}])"
}

genji> explain select * from foo where a > 10 AND a < 120 OR a > 4 AND a < 100;
{
   "plan": "table.Scan(\"foo\", [{\"min\": [4], \"max\": [120], \"exclusive\": true}])"
}
@asdine asdine added this to the v0.16.0 milestone Jul 2, 2022
@asdine asdine added the planner label Jul 2, 2022
@asdine asdine modified the milestones: v0.16.0, v0.17.0 Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant