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

Joins missing optimal indexes #5993

Closed
max-hoffman opened this issue May 19, 2023 · 1 comment
Closed

Joins missing optimal indexes #5993

max-hoffman opened this issue May 19, 2023 · 1 comment
Labels
analyzer bug Something isn't working sql Issue with SQL

Comments

@max-hoffman
Copy link
Contributor

We fail to discover some lookup keys during join planning. For example, the query below is a CROSS_JOIN because there is no join condition, but the WHERE filter places functional restrictions on columns x and y: ()->(x) and ()->(y):

select *
from xy
cross join uv
where x = 1 and y = 2

Because of this we can execute this plan as LOOKUP_JOIN(uv, xy key(1)). Normally we would need to produce a scalar (x) key from the u row, for example if u=x => LOOKUP_JOIN(uv, xy key(gf(0)). The scalar restriction satisfies the necessary condition just in a less direct way.

The join above is trivial, but many more elaborate joins benefit from the same treatment. Scalar restrictions and computing equivalence closures lets us more aggressively and safely use index lookups. The issue here #3797 is one example limited in part by our underuse of functional dependence.

This work is related to eliminating unnecessary sorts and tracking null-safety for applyJoin transformations, but not in scope for now. Resources below:

I will start working on getting these basic cases to work, linking progress tickets here.

@max-hoffman
Copy link
Contributor Author

Closing because we've made a lot of progress here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer bug Something isn't working sql Issue with SQL
Projects
None yet
Development

No branches or pull requests

2 participants