Skip to content

rowenc: various improvements to IndexFetchSpec initialization#76795

Merged
craig[bot] merged 5 commits intocockroachdb:masterfrom
RaduBerinde:fetch-stuff-in-descs
Feb 20, 2022
Merged

rowenc: various improvements to IndexFetchSpec initialization#76795
craig[bot] merged 5 commits intocockroachdb:masterfrom
RaduBerinde:fetch-stuff-in-descs

Conversation

@RaduBerinde
Copy link
Copy Markdown
Member

First commit is #76788.

catalog: store IndexFetchSpec key columns in table descriptor

We now cache the IndexFetchSpec_KeyAndSuffixColumns in the table
descriptor, making it cheaper to populate an IndexFetchSpec.

Release note: None

catalog: cleanup KeysPerRow

This change renames KeysPerRow to IndexKeysPerRow and changes the
argument to an IndexDescriptor, removing the error case.

Release note: None

catalog: cache family default columns in table descriptor

We now cache the IndexFetchSpec_FamilyDefaultColumns in the table
descriptor, to avoid an allocation when creating an IndexFetchSpec.

Release note: None

rowenc: calculate key prefix length without allocating

We now calculate the key prefix length directly instead of creating a
throw-away key.

Release note: None

This commit removes a check that fails creation of an IndexFetchSpec
if a key column is not public.

The only case where this comes up AFAICT is when we hit a duplicate
key error and try to fetch the row to get the values for the error
message. In this case, even though the column is not public, we know
that the row we care about exists in the index, or we wouldn't have
hit the error.

Release note: None
@RaduBerinde RaduBerinde requested review from a team and yuzefovich February 18, 2022 22:58
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@RaduBerinde RaduBerinde changed the title rowenc: calculate key prefix length without allocating rowenc: various improvements to IndexFetchSpec initialization Feb 18, 2022
Copy link
Copy Markdown
Member

@yuzefovich yuzefovich 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 2 of 2 files at r1, 4 of 4 files at r2, 6 of 6 files at r3, 4 of 4 files at r4, 3 of 3 files at r5, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @RaduBerinde)


pkg/sql/catalog/descriptor.go, line 512 at r2 (raw file):

	IndexStoredColumns(idx Index) []Column

	// FetchSpecKeyAndSuffixColumns returns information about the key and suffix

nit: s/FetchSpec/IndexFetchSpec/.


pkg/sql/catalog/tabledesc/column.go, line 382 at r2 (raw file):

		invertedColumnID = idx.InvertedColumnID()
	}
	var compositeIDs catalog.TableColSet

nit: I think you can do idx.CollectCompositeColumnIDs for this.


pkg/sql/catalog/tabledesc/column.go, line 390 at r2 (raw file):

		col := ic.all[i]
		if col == nil {
			// This is an invalid descriptor.

When can this occur? Maybe extend a comment?


pkg/sql/rowenc/index_fetch.go, line 35 at r2 (raw file):

	fetchColumnIDs []descpb.ColumnID,
) error {
	//oldKeyAndSuffixCols := s.KeyAndSuffixColumns

nit: seems like there are some leftovers in this file in the second commit.

We now cache the IndexFetchSpec_KeyAndSuffixColumns in the table
descriptor, making it cheaper to populate an IndexFetchSpec.

Release note: None
This change renames KeysPerRow to IndexKeysPerRow and changes the
argument to an IndexDescriptor, removing the error case.

Release note: None
We now cache the `IndexFetchSpec_FamilyDefaultColumn`s in the table
descriptor, to avoid an allocation when creating an `IndexFetchSpec`.

Release note: None
We now calculate the key prefix length directly instead of creating a
throw-away key.

Release note: None
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.

TFTR!

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


pkg/sql/catalog/tabledesc/column.go, line 382 at r2 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

nit: I think you can do idx.CollectCompositeColumnIDs for this.

That's an Index method, we only have a descpb.IndexDescriptor here.


pkg/sql/catalog/tabledesc/column.go, line 390 at r2 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

When can this occur? Maybe extend a comment?

Added to a comment above. There are other weird things I had to tolerate (like nil columns or 0 column IDs).

@RaduBerinde
Copy link
Copy Markdown
Member Author

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Feb 19, 2022

Build failed:

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.

bors r+

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

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Feb 20, 2022

Build succeeded:

@craig craig bot merged commit ae6d033 into cockroachdb:master Feb 20, 2022
@RaduBerinde RaduBerinde deleted the fetch-stuff-in-descs branch February 20, 2022 19: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.

3 participants