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

sql: better query planning for OR expressions #2142

Open
petermattis opened this issue Aug 18, 2015 · 6 comments

Comments

@petermattis
Copy link
Contributor

commented Aug 18, 2015

Consider a query like SELECT * FROM foo WHERE a > 1 OR b > 2. Even if there are appropriate indexes to satisfy both a > 1 and b > 2, the current query planner will perform a full table or index scan because it can't use both conditions at once. Instead, the query planner should check to see if 2 separate index scans can be used and their results merged using a "union" operation.

This is essentially a generalization of #2140.

@petermattis petermattis added the SQL label Aug 18, 2015

@petermattis petermattis added this to the Beta milestone Aug 18, 2015

@petermattis petermattis self-assigned this Aug 18, 2015

@jess-edwards jess-edwards referenced this issue Aug 20, 2015

Closed

Product Roadmap #2132

49 of 78 tasks complete

petermattis added a commit that referenced this issue Aug 27, 2015

petermattis added a commit that referenced this issue Aug 28, 2015

petermattis added a commit that referenced this issue Aug 28, 2015

petermattis added a commit that referenced this issue Aug 28, 2015

Add support for scanning multiple spans for a single index.
Index selection now creates multiple independent spans of the index that
must be scanned. Multiple spans are created for expressions like "a
IN (1, 2, 3)" and "a = 1 OR a = 2 or a = 3" (these are equivalent).

Fixes #2140.
See #2142.

petermattis added a commit that referenced this issue Aug 28, 2015

Add support for scanning multiple spans for a single index.
Index selection now creates multiple independent spans of the index that
must be scanned. Multiple spans are created for expressions like "a
IN (1, 2, 3)" and "a = 1 OR a = 2 or a = 3" (these are equivalent).

Fixes #2140.
See #2142.

petermattis added a commit that referenced this issue Aug 28, 2015

Add support for scanning multiple spans for a single index.
Index selection now creates multiple independent spans of the index that
must be scanned. Multiple spans are created for expressions like "a
IN (1, 2, 3)" and "a = 1 OR a = 2 or a = 3" (these are equivalent).

Fixes #2140.
See #2142.
@petermattis

This comment has been minimized.

Copy link
Contributor Author

commented Sep 10, 2015

We really want UNION before implementing this. I'm going to punt it to 1.0 for now.

@petermattis petermattis modified the milestones: 1.0, Beta Sep 10, 2015

@petermattis petermattis removed their assignment Oct 30, 2015

@petermattis petermattis added C-enhancement and removed SQL labels Feb 13, 2016

@spencerkimball

This comment has been minimized.

Copy link
Member

commented Mar 28, 2017

@RaduBerinde @knz is this still an active issue? Should it be 1.0 if so? If not, please close.

@knz

This comment has been minimized.

Copy link
Member

commented Mar 28, 2017

@spencerkimball spencerkimball removed this from the 1.0 milestone Mar 28, 2017

@dianasaur323 dianasaur323 added this to the 1.1 milestone Apr 20, 2017

@jseldess

This comment has been minimized.

Copy link
Contributor

commented May 10, 2017

Document this as known limitation with cockroachdb/docs#1381 (review). @knz, @petermattis, please review my language there and let me know if we need to add a workaround.

@jseldess jseldess added the docs-done label May 10, 2017

@knz knz added the C-performance label Jun 7, 2017

@knz knz referenced this issue Jun 7, 2017

Closed

sql: tracking issue, proposed optimizations #12418

5 of 14 tasks complete
@knz

This comment has been minimized.

Copy link
Member

commented Jun 7, 2017

Deassigning myself as I am not working on this before a suitable IR.
The item is now listed on #12418 though.

@knz knz removed their assignment Jun 7, 2017

@petermattis petermattis modified the milestones: Later, 1.1 Jun 30, 2017

@knz knz added the A-sql-planning label Apr 28, 2018

@andy-kimball andy-kimball modified the milestones: Later, 2.2 Aug 24, 2018

@andy-kimball

This comment has been minimized.

Copy link
Contributor

commented Aug 24, 2018

Pushing to 2.2. We could add a rule to map disjunctions to UNION queries in appropriate cases (probably exploration rule?).

@andy-kimball andy-kimball added this to Higher Priority Backlog in SQL Planning Aug 25, 2018

@petermattis petermattis removed this from the 2.2 milestone Oct 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.