-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
sql: add NotVisible to index descriptor #84763
Conversation
1632058
to
4cd6576
Compare
0b910a7
to
a4610f6
Compare
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.
message: ThisPR {
optional bool lgtm = 1 [(gogoproto.nullable) = false];
}
return &ThisPR{lgtm: true}
Reviewed 24 of 24 files at r1, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @mgartner and @postamar)
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.
Very nicely done! Let's get someone on SQL Schema to stamp this before merging.
Reviewed 24 of 24 files at r1, all commit messages.
Reviewable status: complete! 2 of 0 LGTMs obtained (waiting on @postamar and @wenyihu6)
-- commits
line 2 at r1:
nit: we prefer to use the imperative mood for commit titles, like sql: add NotVisible to index descriptor
I think we typically use the present tense in the commit body (e.g. "This PR adds ..." rather than "This PR added ..."), but I don't see that as an official guideline in the doc linked above, so that's up to you if you want to change it.
-- commits
line 4 at r1:
super nit: PR => commit
pkg/sql/catalog/catformat/index.go
line 179 at r1 (raw file):
if index.NotVisible { f.WriteString(" NOT VISIBLE")
Reminder to add tests for this with SHOW CREATE TABLE
once not visible indexes can be added.
pkg/sql/opt/indexrec/hypothetical_index.go
line 52 at r1 (raw file):
// notVisible indicates if an index is not visible to the optimizer. notVisible bool
I don't think we need this field, we can just always return false in IsNotVisible
below. I don't see a case where we'd make a recommendation to the user to create an invisible index.
You could add a TODO here to handle cases where an invisible index exists that should be made non-visible to improve the query plan.
pkg/sql/schemachanger/scbuild/internal/scbuildstmt/create_index.go
line 46 at r1 (raw file):
IsInverted: n.Inverted, IsConcurrently: n.Concurrently, IsNotVisible: false, // TODO(wenyihu6): populate hidden property after CREATE
nit: hidden => IsNotVisible
a4610f6
to
9c18b23
Compare
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.
LGTM
This commit adds a new field `NotVisible` to the struct `IndexDescriptor`. Since primary indexes cannot be not visible, it also includes another check in `pkg/sql/catalog/tabledesc/validate.go`. Since the invisible index feature has not been introduced yet, all indexes created should be visible. See also: cockroachdb#84776 Assists: cockroachdb#72576 Release note: none
Previously, mgartner (Marcus Gartner) wrote…
Done. |
Previously, mgartner (Marcus Gartner) wrote…
Done. |
9c18b23
to
b91b031
Compare
bors r+ |
Build succeeded: |
This commit adds a new field
NotVisible
to the structIndexDescriptor
. Sinceprimary indexes cannot be not visible, it also includes another check in
pkg/sql/catalog/tabledesc/validate.go
. Since the invisible index feature hasnot been introduced yet, all indexes created should be visible.
See also: #84776
Assists: #72576
Release note: none