-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 hash joins when nested loop joins are not feasible #14448
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
vitess-bot
bot
added
NeedsDescriptionUpdate
The description is not clear or comprehensive enough, and needs work
NeedsIssue
A linked issue is missing for this Pull Request
NeedsWebsiteDocsUpdate
What it says
labels
Nov 3, 2023
systay
force-pushed
the
use-hash-joins
branch
from
November 3, 2023 07:53
373a587
to
560f8e2
Compare
systay
added
Type: Feature
Component: Query Serving
and removed
NeedsDescriptionUpdate
The description is not clear or comprehensive enough, and needs work
NeedsWebsiteDocsUpdate
What it says
NeedsIssue
A linked issue is missing for this Pull Request
labels
Nov 3, 2023
systay
force-pushed
the
use-hash-joins
branch
6 times, most recently
from
November 14, 2023 07:52
6768501
to
61a1344
Compare
systay
added
Type: Enhancement
Logical improvement (somewhere between a bug and feature)
and removed
Type: Feature
labels
Nov 14, 2023
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
systay
force-pushed
the
use-hash-joins
branch
from
November 16, 2023 07:56
61a1344
to
5ac5d36
Compare
systay
force-pushed
the
use-hash-joins
branch
from
November 16, 2023 07:57
5ac5d36
to
93cca85
Compare
systay
requested review from
harshit-gangal,
shlomi-noach,
rohit-nayak-ps,
frouioui,
GuptaManan100,
arthurschreiber and
vmg
as code owners
November 16, 2023 07:57
The produced plans still need optimising - this PR only makes the queries possible, they are still going to be very slow. Optimisation work incoming |
vmg
approved these changes
Nov 16, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking gucci my friend
GuptaManan100
approved these changes
Nov 16, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Component: Query Serving
Type: Enhancement
Logical improvement (somewhere between a bug and feature)
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The join we to use in vtgate is the apply join, also known as nested loop join. It's algorithm is pretty straight forward - we execute the query on the LHS of the join, and then, for each row in this result, we extract the join columns from the left and push them down on the RHS of the join, and use them for filtering there.
This works well in most situations. One issue is that we can't have the outer side on the LHS of the join - we won't see the values that are coming from the RHS that don't match anything on the left.
Another limitation is that we can't really have LIMIT on the RHS either. Our engine primitives understand a call to the
Execute
method as a new query. Since we will need to do multipleExecute
calls on the RHS,LIMIT
s there will produce too many rows. ALIMIT 10
will produce 10 rows per row on the LHS, and that is not correct.To solve this, we have a couple of options. One would be to introduce a query scope for the engine primitives.
In this PR I'm trying using the hash join engine primitive for these queries. Since it executes the LHS and the RHS on their own and then joins the result, we can allow outer joins and limits on either/both sides.
Related Issue(s)
Fixes #11879
Checklist