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

release-20.2: opt: allow IN subquery to be converted to lookup join #63869

Merged
merged 2 commits into from
Apr 20, 2021

Conversation

RaduBerinde
Copy link
Member

Backport 2/2 commits from #63780.

/cc @cockroachdb/release


opt: add opttester facility to test placeholder assignment

We like to assume that the result of building a memo with placeholders
followed by AssignPlaceholders is equivalent to building the query
with the values directly. This is not necessarily the case - it is
possible that some normalization rules act on a higher part of the
tree in a way that would not happen if we had fully normalized a lower
part of the tree.

This commit adds two new opttester directives:
assign-placeholders-norm and assign-placeholders-opt. These take a
query that has placeholders and simulates the prepared query planning
path.

We use these facilities to add some tests that reproduce a customer
issue.

Release note: None

opt: allow IN subquery to be converted to lookup join

This change adds a rule that handles a case which prevents Exists
subqueries from becoming lookup joins.

Fixes #43198.

Release note (performance improvement): certain queries containing
<tuple> IN (<subquery>) conditions may run significantly faster.

We like to assume that the result of building a memo with placeholders
followed by AssignPlaceholders is equivalent to building the query
with the values directly. This is not necessarily the case - it is
possible that some normalization rules act on a higher part of the
tree in a way that would not happen if we had fully normalized a lower
part of the tree.

This commit adds two new opttester directives:
`assign-placeholders-norm` and `assign-placeholders-opt`. These take a
query that has placeholders and simulates the prepared query planning
path.

We use these facilities to add some tests that reproduce a customer
issue.

Release note: None
This change adds a rule that handles a case which prevents Exists
subqueries from becoming lookup joins.

Fixes cockroachdb#43198.

Release note (performance improvement): certain queries containing
`<tuple> IN (<subquery>)` conditions may run significantly faster.
@RaduBerinde RaduBerinde requested review from mgartner and rytaft April 19, 2021 19:20
@RaduBerinde RaduBerinde requested a review from a team as a code owner April 19, 2021 19:20
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@mgartner mgartner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 4 of 4 files at r1, 5 of 5 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @rytaft)

@RaduBerinde RaduBerinde merged commit 2de84b0 into cockroachdb:release-20.2 Apr 20, 2021
@RaduBerinde RaduBerinde deleted the backport20.2-63780 branch April 20, 2021 04:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants