Skip to content

opt/idxconstraint: recognize stored column expressions#55867

Merged
craig[bot] merged 2 commits intocockroachdb:masterfrom
RaduBerinde:idx-constraints-computed
Oct 28, 2020
Merged

opt/idxconstraint: recognize stored column expressions#55867
craig[bot] merged 2 commits intocockroachdb:masterfrom
RaduBerinde:idx-constraints-computed

Conversation

@RaduBerinde
Copy link
Copy Markdown
Member

deps: update datadriven

Release note: None

opt/idxconstraint: recognize stored column expressions

This change makes the index constraint generator aware of computed
column expressions so it can substitute them for the computed column
if it is indexed.

Release note (performance improvement): indexes on computed columns
can now be utilized when filters reference the computed expression and
not the computed column directly.

@RaduBerinde RaduBerinde requested a review from mgartner October 22, 2020 18:25
@RaduBerinde RaduBerinde requested a review from a team as a code owner October 22, 2020 18:25
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@RaduBerinde RaduBerinde force-pushed the idx-constraints-computed branch from e60ff91 to 5f77421 Compare October 22, 2020 19:39
Copy link
Copy Markdown
Collaborator

@rytaft rytaft left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 3 of 3 files at r1, 6 of 6 files at r2.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @mgartner and @RaduBerinde)


pkg/sql/opt/idxconstraint/index_constraints.go, line 1428 at r2 (raw file):

}

// isIndexColumn returns true if ev is a variable on the n indexed var that

I think this comment is a bit stale

Copy link
Copy Markdown
Contributor

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

:LGTM:

Reviewed 3 of 3 files at r1, 6 of 6 files at r2.
Reviewable status: :shipit: complete! 2 of 0 LGTMs obtained (waiting on @RaduBerinde)


pkg/sql/opt/xform/testdata/rules/select, line 1646 at r2 (raw file):

 └── scan computed@l_idx
      ├── columns: k:1!null
      ├── constraint: /3/1: [/'foo' - /'foo']

Maybe the formatted constraint should include the column name, like /l:3/k:1? The column ID 3 appears no where else in this output, so it's not clear that it is l. No need to make this change for this PR, but something we should think about.

Release note: None
@RaduBerinde RaduBerinde force-pushed the idx-constraints-computed branch 2 times, most recently from 66ab240 to 1f6de5a Compare October 28, 2020 16:36
Copy link
Copy Markdown
Member Author

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

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


pkg/sql/opt/idxconstraint/index_constraints.go, line 1428 at r2 (raw file):

Previously, rytaft (Rebecca Taft) wrote…

I think this comment is a bit stale

Done.


pkg/sql/opt/xform/testdata/rules/select, line 1646 at r2 (raw file):

Previously, mgartner (Marcus Gartner) wrote…

Maybe the formatted constraint should include the column name, like /l:3/k:1? The column ID 3 appears no where else in this output, so it's not clear that it is l. No need to make this change for this PR, but something we should think about.

Good idea, I'll look at that separately.

Copy link
Copy Markdown
Collaborator

@rytaft rytaft left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 9 files at r3, 6 of 6 files at r4.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 2 stale) (waiting on @mgartner and @RaduBerinde)


pkg/sql/opt/idxconstraint/index_constraints.go, line 1428 at r2 (raw file):

Previously, RaduBerinde wrote…

Done.

It still references ev which doesn't exist.

This change makes the index constraint generator aware of computed
column expressions so it can substitute them for the computed column
if it is indexed.

Release note (performance improvement): indexes on computed columns
can now be utilized when filters reference the computed expression and
not the computed column directly.
@RaduBerinde RaduBerinde force-pushed the idx-constraints-computed branch from 1f6de5a to cad8242 Compare October 28, 2020 16:47
Copy link
Copy Markdown
Member Author

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

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


pkg/sql/opt/idxconstraint/index_constraints.go, line 1428 at r2 (raw file):

Previously, rytaft (Rebecca Taft) wrote…

It still references ev which doesn't exist.

Fixed.

Copy link
Copy Markdown
Collaborator

@rytaft rytaft left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r5.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 2 stale) (waiting on @mgartner)

@RaduBerinde
Copy link
Copy Markdown
Member Author

bors r+

1 similar comment
@RaduBerinde
Copy link
Copy Markdown
Member Author

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Oct 28, 2020

Already running a review

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Oct 28, 2020

Build succeeded:

@craig craig bot merged commit 4438c83 into cockroachdb:master Oct 28, 2020
@RaduBerinde RaduBerinde deleted the idx-constraints-computed branch October 29, 2020 20:53
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.

4 participants