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: add helper functions for partial indexes and scans #51232

Merged
merged 1 commit into from
Jul 10, 2020

Conversation

mgartner
Copy link
Collaborator

@mgartner mgartner commented Jul 9, 2020

This commit adds helper functions to determine if indexes are partial
indexes, if scans operate on partial indexes, and for retrieving partial
index predicate expressions.

Within the optimizer TableMeta.PartialIndexPredicates is now the
source of truth that should be used for answering these types of
questions. The catalog Index.Predicate function should only be used by
the optbuilder.

This commit also makes certain that there is an entry in the
TableMeta.PartialIndexPredicates map for every partial index on the
table, even if the partial index predicate is non-immutable. This makes
the map a safe source of truth for determining which indexes are
partial.

Release note: None

This commit adds helper functions to determine if indexes are partial
indexes, if scans operate on partial indexes, and for retrieving partial
index predicate expressions.

Within the optimizer `TableMeta.PartialIndexPredicates` is now the
source of truth that should be used for answering these types of
questions. The catalog `Index.Predicate` function should only be used by
the optbuilder.

This commit also makes certain that there is an entry in the
`TableMeta.PartialIndexPredicates` map for every partial index on the
table, even if the partial index predicate is non-immutable. This makes
the map a safe source of truth for determining which indexes are
partial.

Release note: None
@mgartner mgartner requested a review from a team as a code owner July 9, 2020 18:30
@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)


pkg/sql/opt/memo/expr.go, line 812 at r1 (raw file):

}

// IsPartialIndex returns true if the table's index at the given ordinal is

[nit] should these be methods of TableMeta?

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! 1 of 0 LGTMs obtained (waiting on @RaduBerinde)


pkg/sql/opt/memo/expr.go, line 812 at r1 (raw file):

Previously, RaduBerinde wrote…

[nit] should these be methods of TableMeta?

IsPartialIndex could be, but PartialIndexPredicate cannot because it returns a memo.FiltersExpr, and the memo package can't be used from the opt package. I wanted this function to do the type cast rather than have each caller do the cast. And I think it's best to keep both of these functions together rather than put one in TableMeta and one here.

@mgartner
Copy link
Collaborator Author

bors r=RaduBerinde

@RaduBerinde
Copy link
Member


pkg/sql/opt/memo/expr.go, line 812 at r1 (raw file):

Previously, mgartner (Marcus Gartner) wrote…

IsPartialIndex could be, but PartialIndexPredicate cannot because it returns a memo.FiltersExpr, and the memo package can't be used from the opt package. I wanted this function to do the type cast rather than have each caller do the cast. And I think it's best to keep both of these functions together rather than put one in TableMeta and one here.

👍

@craig
Copy link
Contributor

craig bot commented Jul 10, 2020

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.

3 participants