-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Optimize SELECT UNNEST in lateral joins #6035
Conversation
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.
Thanks for the PR! Looks good! Great performance gains.
I have been playing around with this for a bit and found this query does not work yet:
SELECT UNNEST(j) FROM (VALUES ([[1, 2, 3]]), ([[4, 5]])) t(i), (SELECT UNNEST(i)) t2(j);
Could you have a look at that?
Looks good to me otherwise.
Thanks for the find! I updated the implementation to skip unknown parent operators instead of throwing an internal exception, so this query works now! :) |
Thanks for the changes! |
This PR adds the
unnest_rewriter
to the optimizer. While the two queries below are semantically equal, their query plans currently differ. The second query performs a duplicate eliminated join (DelimJoin
), which is the default approach for lateral joins.However, a
DelimJoin
is not required forUNNESTs
in theFROM
clause. Instead, we can eliminate theDelimJoin
. Then, we make theUNNEST
the direct child of the former parent of theDelimJoin
. Together with #5982, this PR tackles the performance issues in #5827.Here are two query plans for comparison.
Current master branch.
This PR.