-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Add index and table metrics to vttablet #17570
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
Conversation
* IndexBytes * IndexCardinality * TableClusteredIndexSize * TableRows Signed-off-by: Rafer Hazen <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Signed-off-by: Rafer Hazen <[email protected]>
Signed-off-by: Rafer Hazen <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17570 +/- ##
==========================================
- Coverage 67.57% 67.55% -0.03%
==========================================
Files 1598 1598
Lines 260044 260213 +169
==========================================
+ Hits 175735 175793 +58
- Misses 84309 84420 +111 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| includeStats = false | ||
|
|
||
| innodbResults, err := conn.Conn.Exec(ctx, innodbTableSizesQuery, maxTableCount, false) | ||
| innodbResults, err := conn.Conn.Exec(ctx, innodbTableSizesQuery, maxTableCount*maxPartitionsPerTable, false) |
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.
Increased this because even with our limit of 10k tables, it's possible that there are more partitions than that (and this query returns one row per partition).
| } | ||
| } | ||
| if err := se.updateTableIndexMetrics(ctx, conn.Conn); err != nil { | ||
| log.Errorf("Updating index/table statistics failed, error: %v", err) |
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.
This just logs instead of failing the method. I figure if updateTableIndexMetrics fails it's better to continue on since the only impact is missing metrics.
|
@deepthi We're hoping to keep moving forward on https://github.com/planetscale/surfaces/issues/2679 and this change is (unfortunately!) a blocker. Would you be able to help us get it into the queue for review? If it already is, ignore me! |
GuptaManan100
left a comment
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
Signed-off-by: Rafer Hazen <[email protected]>
Signed-off-by: Rafer Hazen <[email protected]>
Signed-off-by: Rafer Hazen <[email protected]>
Signed-off-by: Florent Poinsard <[email protected]>
d875d5e to
0f5469e
Compare
Signed-off-by: Rafer Hazen <[email protected]>
Signed-off-by: Rafer Hazen <[email protected]>
…stats Signed-off-by: Rafer Hazen <[email protected]>
Signed-off-by: Rafer Hazen <[email protected]>
Signed-off-by: Rafer Hazen <[email protected]>
Signed-off-by: Rafer Hazen <[email protected]>
Signed-off-by: Rafer Hazen <[email protected]>
|
This is ready for another round of review. |
Description
This adds the following metrics to vttablet's schema engine.
TableRows(by table) - The estimated number of rows in the tableTableClusteredIndexSize(by table) - The size of the clustered index (i.e. the size of the "row data")IndexCardinality(by index) - The estimated number of unique values in the indexIndexBytes(by index) - The size of the indexmetrics sample
These values are read from mysql system tables when
Engine#Reloadis called, and made available viaEnv#ExporterPartition names
Since mysql implements partitions internally as one table per partition, the "table name" referenced in the stats tables mostly look like
TABLE_NAME#p#PARTITION_NAME. We want to report statistics per logical table (not per partition) so we need a way to extract the underlying table name. Unfortunately, it's not as simple as splitting the composite name by#p#, because it's possible to create a table or partition with#p#as a part of the name.The approach I took here is to load the
information_schema.partitionstable, which includes separate columns for the table and partition name. Then, as we read through the stats tables that contain the composite name, if we encounter a#p#, we attempt to find a matching table/partition in the loaded list, and, if it is present, we can find the base table name.An alternative method would be to make use of
information_schema.innodb_tables.namecolumn (like we do here), which provides the table name with special characters encoded. This makes it possible to confidently split on#p#, because the#characters would be encoded if they were part of the real table or partition name. I opted for the "loading all partitions" approach instead because the joins required to get an encoded table name made the queries too slow when there are many tables, indexes or partitions.Performance
Since performance of the queries run on
#Reloadhas been an issue in the past, I tested the queries added in this PR with the following test setup.Results:
updateTableIndexMetricsmethod:716ms37ms15ms205ms427msFor comparison the
InnoDBTableSizesquery takes2.0sfor the same test setup.Related Issue(s)
Checklist
Deployment Notes
None