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

db: add range key table stats #1616

Merged
merged 2 commits into from
Apr 4, 2022

Conversation

nicktrav
Copy link
Contributor

Two commits in this series - the first is a code shuffle (no logic changes); the second has the additions.


db: factor out some table stats helpers

To improve readability, factor out the logic to populate the point and
range key table stats into their own separate methods. This also allows
for adding a separate method for range keys in the future, if the logic
becomes complex enough.

db: add range key count to table stats

Range key-related statistics are not currently calculated and stored in
a table's FileMetadata, and are required for compaction picking.

Add a NumRangeKeys field to manifest.TableStats which is populated
by the total number of range keys present in a table (the sum of range
key sets, unsets and deletes).

@nicktrav nicktrav requested review from itsbilal and jbowens March 31, 2022 23:35
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@nicktrav nicktrav mentioned this pull request Mar 31, 2022
29 tasks
Copy link
Collaborator

@jbowens jbowens 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 1 of 1 files at r1, 10 of 11 files at r2, all commit messages.
Reviewable status: 10 of 11 files reviewed, 4 unresolved discussions (waiting on @itsbilal and @nicktrav)


-- commits, line 5 at r1:
s/range key/range deletion/


-- commits, line 7 at r1:
Just a heads up, for producing delete-only compactions we'll need to examine both range deletions and range keys in tandem, which might throw a wrench in factoring range keys into their own method.


table_stats.go, line 294 at r1 (raw file):

}

// loadTablePointKeyStats calculates the range deletion statistics for the given

s/loadTablePointKeyStats/sloadTableRangeDelStats/


testdata/table_stats, line 184 at r2 (raw file):

Previously, nicktrav (Nick Travers) wrote…

Curiously, these crept in due to the use of the testkeys.Comparer. I need to dig into why exactly, but it seems benign.

I bet it's just the comparer name which gets serialized into the sstable properties. The range-deletion-bytes-estimate includes the full size of sstables that are wholly contained by a rangedel, so that does include the properties block.

nicktrav added 2 commits April 4, 2022 10:48
To improve readability, factor out the logic to populate the point and
range deletion table stats into their own separate methods. This also
allows for adding a separate method for range keys in the future, if the
logic becomes complex enough.
Range key-related statistics are not currently calculated and stored in
a table's `FileMetadata`, and are required for compaction picking.

Add a `NumRangeKeys` field to `manifest.TableStats` which is populated
by the total number of range keys present in a table (the sum of range
key sets, unsets and deletes).
@nicktrav nicktrav force-pushed the nickt.rk-table-stats branch from f342710 to a2e377b Compare April 4, 2022 17:52
Copy link
Contributor Author

@nicktrav nicktrav 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: 0 of 11 files reviewed, 3 unresolved discussions (waiting on @itsbilal and @jbowens)


-- commits, line 5 at r1:

Previously, jbowens (Jackson Owens) wrote…

s/range key/range deletion/

Done.


-- commits, line 7 at r1:

Previously, jbowens (Jackson Owens) wrote…

Just a heads up, for producing delete-only compactions we'll need to examine both range deletions and range keys in tandem, which might throw a wrench in factoring range keys into their own method.

Ah - good to know. Will see how this plays out.


table_stats.go, line 294 at r1 (raw file):

Previously, jbowens (Jackson Owens) wrote…

s/loadTablePointKeyStats/sloadTableRangeDelStats/

Done.


testdata/table_stats, line 184 at r2 (raw file):

Previously, jbowens (Jackson Owens) wrote…

I bet it's just the comparer name which gets serialized into the sstable properties. The range-deletion-bytes-estimate includes the full size of sstables that are wholly contained by a rangedel, so that does include the properties block.

Ah nice.

func TestLen(t *testing.T) {
	fmt.Println(len(testkeys.Comparer.Name))    // 24
	fmt.Println(len(base.DefaultComparer.Name)) // 26
}

@nicktrav nicktrav merged commit c8e7d41 into cockroachdb:master Apr 4, 2022
@nicktrav nicktrav deleted the nickt.rk-table-stats branch April 4, 2022 18:10
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