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

opt: plan inner lookup joins on virtual column indexes in more cases #76078

Merged
merged 1 commit into from
Feb 8, 2022

Conversation

mgartner
Copy link
Collaborator

@mgartner mgartner commented Feb 4, 2022

ExtractJoinEqualities now reuses computed columns instead of
synthesizing new columns when it creates projections that exactly match
a computed column expression of a base table. This allows
GenerateLookupJoinsWithVirtualCols to generate lookup joins in more
cases. This also paves the way for exploring anti- and semi-lookup
joins on indexes with virtual columns and expression indexes.

Fixes #75872

Release note (performance improvement): The optimizer now plans inner
lookup joins using expression indexes in more cases, resulting in more
efficient query plans.

@mgartner mgartner requested review from msirek, RaduBerinde and a team February 4, 2022 18:57
@mgartner mgartner requested a review from a team as a code owner February 4, 2022 18:57
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @mgartner and @msirek)


pkg/sql/opt/xform/testdata/rules/join, line 4144 at r1 (raw file):


# Covering case. Join on virtual column expression but do not produce it.
# opt expect=GenerateLookupJoinsWithVirtualCols

[nit] is the variant with expect= not working? Same on more testcases below

Copy link
Contributor

@msirek msirek left a comment

Choose a reason for hiding this comment

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

I spent quite some time trying to understand the column id mapping code for virtual columns and related logic, to see if there could be potential problems. I couldn't find any issues.

:lgtm:

Reviewable status: :shipit: complete! 2 of 0 LGTMs obtained (waiting on @mgartner and @RaduBerinde)

@mgartner mgartner force-pushed the computed-column-projections branch from 56b5ce5 to 55ce1dc Compare February 7, 2022 16:05
Copy link
Collaborator Author

@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.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 2 stale) (waiting on @RaduBerinde)


pkg/sql/opt/xform/testdata/rules/join, line 4144 at r1 (raw file):

Previously, RaduBerinde wrote…

[nit] is the variant with expect= not working? Same on more testcases below

Nope, just something I forgot to clean up. Thanks for catching.

ExtractJoinEqualities now reuses computed columns instead of
synthesizing new columns when it creates projections that exactly match
a computed column expression of a base table. This allows
GenerateLookupJoinsWithVirtualCols to generate lookup joins in more
cases. This also paves the way for exploring  anti- and semi-lookup
joins on indexes with virtual columns and expression indexes.

Fixes cockroachdb#75872

Release note (performance improvement): The optimizer now plans inner
lookup joins using expression indexes in more cases, resulting in more
efficient query plans.
@mgartner mgartner force-pushed the computed-column-projections branch from 55ce1dc to 82b6db4 Compare February 7, 2022 20:05
@mgartner
Copy link
Collaborator Author

mgartner commented Feb 8, 2022

bors r+

@craig
Copy link
Contributor

craig bot commented Feb 8, 2022

Build succeeded:

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.

opt: plan lookup joins on indexes with virtual columns in more cases
4 participants