Skip to content

sql: add partial statistics predicate column to system.table_statistics#91248

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
faizaanmadhani:faizaan/predicate-system-table-stats
Nov 8, 2022
Merged

sql: add partial statistics predicate column to system.table_statistics#91248
craig[bot] merged 1 commit intocockroachdb:masterfrom
faizaanmadhani:faizaan/predicate-system-table-stats

Conversation

@faizaanmadhani
Copy link
Copy Markdown
Contributor

@faizaanmadhani faizaanmadhani commented Nov 3, 2022

This commit adds a column to system.table_statistics to store
a string representing the predicate for a partial statistics
collection. Previously, only full table statistics could be
stored in system.table_statistics, and this commit adds
support to store partial table statistics to this table. It
assists Epic CRDB-19449 and is a prerequisite for adding
support for collecting partial statistics.

Epic: CRDB-19449

Release note (sql change): system.table_statistics now
contains a column called partialPredicate to store a
predicate for a partial statistic collection.

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@faizaanmadhani faizaanmadhani force-pushed the faizaan/predicate-system-table-stats branch from 997a253 to bcace43 Compare November 4, 2022 15:35
@faizaanmadhani faizaanmadhani changed the title sql: add partial predicate column to system.table_statistics sql: add partial statistics predicate column to system.table_statistics Nov 4, 2022
@faizaanmadhani faizaanmadhani force-pushed the faizaan/predicate-system-table-stats branch 5 times, most recently from af73bf8 to 117fa59 Compare November 7, 2022 17:08
@faizaanmadhani faizaanmadhani marked this pull request as ready for review November 7, 2022 18:48
@faizaanmadhani faizaanmadhani requested review from a team, michae2 and rytaft November 7, 2022 18:48
@postamar
Copy link
Copy Markdown

postamar commented Nov 7, 2022

Copy link
Copy Markdown

@postamar postamar left a comment

Choose a reason for hiding this comment

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

Schema LGTM

@faizaanmadhani faizaanmadhani force-pushed the faizaan/predicate-system-table-stats branch from 117fa59 to 56e62c2 Compare November 7, 2022 20:34
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.

Nice work! Mostly just some nits.

Reviewed 11 of 11 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @faizaanmadhani and @michae2)


-- commits line 14 at r2:
this is technically a user-visible change, so I'd add a Release note (sql change)


pkg/clusterversion/cockroach_versions.go line 317 at r1 (raw file):

	V23_1Start

	// TenantNames adds a name column to system.tenants.

(Not your change, but this should be V23_1TenantNames)


pkg/clusterversion/cockroach_versions.go line 325 at r1 (raw file):

	V23_1DescIDSequenceForSystemTenant

	// AddPartialPredicateCol adds a column to store the predicate

nit: V23_1AddPartialPredicateCol

Also, I'd call this V23_1AddPartialStatisticsPredicateCol (or V23_1AddTableStatisticsPartialPredicateCol) to make it really clear what this is.


pkg/clusterversion/cockroach_versions.go line 326 at r1 (raw file):

	// AddPartialPredicateCol adds a column to store the predicate
	// for a partial statistics collection

nit: end comments with a period.


pkg/upgrade/upgrades/alter_system_table_partial_predicate.go line 1 at r1 (raw file):

// Copyright 2022 The Cockroach Authors.

I'd name this file alter_table_statistics_partial_predicate.go for consistency with some of the other files (doesn't seem like there is one consistent naming scheme, but I think referencing table_statistics is still better)


pkg/upgrade/upgrades/alter_system_table_partial_predicate.go line 33 at r1 (raw file):

	op := operation{
		name:           "add-table-statistics-partialPredicate-col",
		schemaList:     []string{"total_consumption"},

total_consumption -> partialPredicate


pkg/upgrade/upgrades/alter_system_table_partial_predicate_test.go line 64 at r1 (raw file):

	)

	// Inject the old copy of the descriptor

nit: end comment with period (here and below).


pkg/upgrade/upgrades/alter_system_table_partial_predicate_test.go line 146 at r1 (raw file):

		NextFamilyID: 1,
		PrimaryIndex: descpb.IndexDescriptor{
			Name:                "primary",

nit: can use tabledesc.LegacyPrimaryKeyIndexName

@rytaft
Copy link
Copy Markdown
Collaborator

rytaft commented Nov 7, 2022

-- commits line 4 at r2:
nit: table_statistics

@rytaft rytaft requested a review from a team November 7, 2022 20:57
@faizaanmadhani faizaanmadhani force-pushed the faizaan/predicate-system-table-stats branch 3 times, most recently from dc9860b to 6678f35 Compare November 7, 2022 21:43
Copy link
Copy Markdown
Contributor Author

@faizaanmadhani faizaanmadhani 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 @michae2 and @rytaft)


-- commits line 14 at r2:

Previously, rytaft (Rebecca Taft) wrote…

this is technically a user-visible change, so I'd add a Release note (sql change)

Done.


pkg/clusterversion/cockroach_versions.go line 317 at r1 (raw file):

Previously, rytaft (Rebecca Taft) wrote…

(Not your change, but this should be V23_1TenantNames)

Done.


pkg/clusterversion/cockroach_versions.go line 325 at r1 (raw file):

Previously, rytaft (Rebecca Taft) wrote…

nit: V23_1AddPartialPredicateCol

Also, I'd call this V23_1AddPartialStatisticsPredicateCol (or V23_1AddTableStatisticsPartialPredicateCol) to make it really clear what this is.

Done.


pkg/clusterversion/cockroach_versions.go line 326 at r1 (raw file):

Previously, rytaft (Rebecca Taft) wrote…

nit: end comments with a period.

Done.


pkg/upgrade/upgrades/alter_system_table_partial_predicate.go line 1 at r1 (raw file):

Previously, rytaft (Rebecca Taft) wrote…

I'd name this file alter_table_statistics_partial_predicate.go for consistency with some of the other files (doesn't seem like there is one consistent naming scheme, but I think referencing table_statistics is still better)

Done.


pkg/upgrade/upgrades/alter_system_table_partial_predicate.go line 33 at r1 (raw file):

Previously, rytaft (Rebecca Taft) wrote…

total_consumption -> partialPredicate

Done.


pkg/upgrade/upgrades/alter_system_table_partial_predicate_test.go line 146 at r1 (raw file):

Previously, rytaft (Rebecca Taft) wrote…

nit: can use tabledesc.LegacyPrimaryKeyIndexName

Done.

@faizaanmadhani faizaanmadhani requested a review from rytaft November 7, 2022 21:48
@faizaanmadhani faizaanmadhani force-pushed the faizaan/predicate-system-table-stats branch from 6678f35 to ccebb5a Compare November 7, 2022 21:57
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 8 of 11 files at r3, 2 of 3 files at r4, 1 of 1 files at r5, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @michae2)

@faizaanmadhani faizaanmadhani force-pushed the faizaan/predicate-system-table-stats branch 2 times, most recently from 6fa0404 to eaaf2a9 Compare November 7, 2022 22:42
Copy link
Copy Markdown
Collaborator

@michae2 michae2 left a comment

Choose a reason for hiding this comment

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

:lgtm: Nice!

Reviewed 5 of 11 files at r1, 4 of 11 files at r3, 2 of 3 files at r4, 1 of 1 files at r5, 4 of 4 files at r7, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @faizaanmadhani)


pkg/ccl/logictestccl/tests/fakedist/BUILD.bazel line 13 at r7 (raw file):

        "//pkg/ccl/logictestccl:testdata",  # keep
    ],
    shard_count = 7,

Did these come from ./dev gen bazel --short? I'm not sure why they changed.

@faizaanmadhani
Copy link
Copy Markdown
Contributor Author

faizaanmadhani commented Nov 8, 2022

./dev gen bazel --short

Yes, I'm not sure what caused them to change too, but I'm gonna try rebasing with master and rerunning the build.

@faizaanmadhani faizaanmadhani force-pushed the faizaan/predicate-system-table-stats branch 6 times, most recently from 2ef042a to f8f9b12 Compare November 8, 2022 18:19
This commit adds a column to system.table_statistics to store
a string representing the predicate for a partial statistics
collection. Previously, only full table statistics could be
stored in `system.table_statistics`, and this commit adds
support to store partial table statistics to this table. It
assists Epic CRDB-19449 and is a prerequisite for adding
support for collecting partial statistics.

Epic: CRDB-19449

Release note (sql change): system.table_statistics now
contains a column called partialPredicate to store a
predicate for a partial statistic collection.
@faizaanmadhani faizaanmadhani force-pushed the faizaan/predicate-system-table-stats branch from f8f9b12 to 2e39af4 Compare November 8, 2022 19:27
@faizaanmadhani
Copy link
Copy Markdown
Contributor Author

TFTRs! 🎉

bors r=rytaft,michae2

@craig craig bot merged commit 5504ecc into cockroachdb:master Nov 8, 2022
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Nov 8, 2022

Build succeeded:

faizaanmadhani added a commit to faizaanmadhani/cockroach that referenced this pull request Nov 11, 2022
Previously, the partial statistics rfc indicated
that we would need to add a column to `system.table_statistics`
that would store a boolean indicating that the statistic is
partial. However, the implementation differs from this (cockroachdb#91248)
and instead adds a column to store a string containing a
predicate. This PR updates the RFC to be consistent with this
change.

Release note: None

Epic: CRDB-19449
craig bot pushed a commit that referenced this pull request Nov 15, 2022
91759: rfcs: update the partial stats collection rfc to reflect implementation r=rytaft a=faizaanmadhani

Previously, the partial statistics rfc indicated
that we would need to add a column to `system.table_statistics` 
that would store a boolean indicating that the statistic is partial. 
However, the implementation differs from this (#91248) 
and instead adds a column to store a string containing a predicate. 
This PR updates the RFC to be consistent with this change.

Release note: None

Epic: CRDB-19449

Co-authored-by: Faizaan Madhani <fzmadhani@gmail.com>
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.

5 participants