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

sql: use IndexFetchSpec in TableReader #76394

Merged
merged 2 commits into from
Feb 12, 2022

Conversation

RaduBerinde
Copy link
Member

row: replace fetcher args with IndexFetchSpec

This commit replaces the row fetcher table args with IndexFetchSpec.

Release note: None

sql: use IndexFetchSpec in TableReader

This commit removes the table descriptor from TableReader and replaces
it with an IndexFetchSpec.

Eventually, we will use the same IndexFetchSpec to form the columnar
batch directly in KV.

Release note: None

@RaduBerinde RaduBerinde requested review from a team as code owners February 10, 2022 20:00
@RaduBerinde RaduBerinde requested review from a team and ajwerner and removed request for a team February 10, 2022 20:00
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
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 (waiting on @ajwerner, @jordanlewis, and @yuzefovich)


pkg/sql/catalog/descpb/index_fetch.proto, line 81 at r2 (raw file):

  // TableModificationTime is the timestamp of the transaction which last
  // modified the table descriptor.
  // TODO(radu, otan): take this into account during planning and remove it from

CC @otan

Copy link
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.

Nice!

Reviewed 11 of 11 files at r1, 29 of 29 files at r2, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner, @jordanlewis, and @RaduBerinde)


pkg/ccl/changefeedccl/rowfetcher_cache.go, line 168 at r1 (raw file):

	// TODO(dan): Allow for decoding a subset of the columns.
	publicCols := tableDesc.PublicColumns()
	colIDs := make([]descpb.ColumnID, len(publicCols))

nit: are there many places where we need IDs of all public columns? It might be worth introducing a method on the table descriptor for it.


pkg/ccl/cliccl/debug_backup.go, line 566 at r1 (raw file):

	ctx context.Context, entry backupccl.BackupTableEntry, codec keys.SQLCodec,
) (row.Fetcher, error) {
	colIDs := make([]descpb.ColumnID, len(entry.Desc.PublicColumns()))

nit: looks like here we could reuse the new method.


pkg/sql/catalog/descpb/index_fetch.proto, line 72 at r2 (raw file):

  }

  optional uint32 version = 1 [(gogoproto.nullable) = false];

nit: can you add some words for why we need versioning in this spec, separate from the DistSQL versions?


pkg/sql/execinfrapb/flow_diagram.go, line 170 at r2 (raw file):

		for i := range keyDirs {
			keyDirs[i] = encoding.Ascending
			if tr.FetchSpec.KeyAndSuffixColumns[i].Direction == descpb.IndexDescriptor_ASC {

Shouldn't we use DESC in the conditional?


pkg/sql/row/fetcher_mvcc_test.go, line 86 at r1 (raw file):

	desc := desctestutils.TestingGetPublicTableDescriptor(kvDB, keys.SystemSQLCodec, `d`, `parent`)
	var colIDs []descpb.ColumnID
	for _, col := range desc.PublicColumns() {

nit: ditto


pkg/sql/row/fetcher_test.go, line 55 at r1 (raw file):

		}
	} else {
		for _, col := range publicCols {

nit: ditto

@otan
Copy link
Contributor

otan commented Feb 10, 2022


pkg/sql/catalog/descpb/index_fetch.proto, line 81 at r2 (raw file):

Previously, RaduBerinde wrote…

CC @otan

ack, sorry i haven't had time recently to take a deeper look.

@RaduBerinde RaduBerinde force-pushed the fetch-spec-tablereader branch from b955f0d to 3c9c8a7 Compare February 10, 2022 22:03
@RaduBerinde RaduBerinde requested a review from a team as a code owner February 10, 2022 22:03
@RaduBerinde RaduBerinde force-pushed the fetch-spec-tablereader branch from 3c9c8a7 to b99e59d Compare February 10, 2022 22:17
Copy link
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! 0 of 0 LGTMs obtained (waiting on @ajwerner, @jordanlewis, and @yuzefovich)


pkg/sql/execinfrapb/flow_diagram.go, line 170 at r2 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

Shouldn't we use DESC in the conditional?

Done.

Copy link
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 35 of 35 files at r3, 54 of 54 files at r4, 8 of 8 files at r5, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @ajwerner, @jordanlewis, and @RaduBerinde)


pkg/sql/execinfrapb/flow_diagram.go, line 147 at r5 (raw file):

func (tr *TableReaderSpec) summary() (string, []string) {
	details := make([]string, 0, 3)
	details = append(details, indexDetail(&tr.Table, tr.IndexIdx))

nit: it could have been cleaner to refactor indexDetail in a separate commit (to print out the actual name of the primary index rather than "primary"). Then there would be less changes in the main commit of this PR. I guess at this point it's probably not worth the effort. It might be a good idea to still make such a change.

Copy link
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! 1 of 0 LGTMs obtained (waiting on @ajwerner, @jordanlewis, and @yuzefovich)


pkg/sql/execinfrapb/flow_diagram.go, line 147 at r5 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

nit: it could have been cleaner to refactor indexDetail in a separate commit (to print out the actual name of the primary index rather than "primary"). Then there would be less changes in the main commit of this PR. I guess at this point it's probably not worth the effort. It might be a good idea to still make such a change.

I'll try to do that and open a separate PR, then rebase this one.

@RaduBerinde
Copy link
Member Author


pkg/sql/execinfrapb/flow_diagram.go, line 147 at r5 (raw file):

Previously, RaduBerinde wrote…

I'll try to do that and open a separate PR, then rebase this one.

#76406

Copy link
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.

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @ajwerner, @jordanlewis, and @RaduBerinde)


pkg/sql/execinfrapb/flow_diagram.go, line 147 at r5 (raw file):

Previously, RaduBerinde wrote…

#76406

Sounds good, thanks!

@RaduBerinde RaduBerinde force-pushed the fetch-spec-tablereader branch from b99e59d to 095e8f3 Compare February 11, 2022 16:09
Copy link
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.

Rebased after merging the separate change to flow diagrams.

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

Copy link
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.

Reviewed 62 of 62 files at r6, 62 of 62 files at r7, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @ajwerner and @jordanlewis)

This commit replaces the row fetcher table args with IndexFetchSpec.

Release note: None
@RaduBerinde RaduBerinde force-pushed the fetch-spec-tablereader branch from 095e8f3 to 533e23b Compare February 11, 2022 19:22
Copy link
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.

I made a small change to put the descriptor modification time directly in TableReaderSpec instead of IndexFetchSpec. This keeps the IndexFetchSpec smaller and will reduce the churn if we remove it later.

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

This commit removes the table descriptor from TableReader and replaces
it with an IndexFetchSpec.

Eventually, we will use the same `IndexFetchSpec` to form the columnar
batch directly in KV.

Release note: None
@RaduBerinde RaduBerinde force-pushed the fetch-spec-tablereader branch from 533e23b to 8ba916b Compare February 11, 2022 20:40
@RaduBerinde
Copy link
Member Author

bors r+

@craig craig bot merged commit 0aacc53 into cockroachdb:master Feb 12, 2022
@craig
Copy link
Contributor

craig bot commented Feb 12, 2022

Build succeeded:

@RaduBerinde RaduBerinde deleted the fetch-spec-tablereader branch February 16, 2022 15:31
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