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

Collect innodb table and index stats #529

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

pgporada
Copy link

@pgporada pgporada commented Feb 5, 2021

Hi,

We found this information useful in troubleshooting some database performance issues at my job. I hope this information can be useful for others who run multi-TB sized databases with tons of indices.

Information regarding these metrics can be found at

The metric descriptions where mostly copy pasted from https://dev.mysql.com/doc/refman/5.6/en/innodb-persistent-stats.html

Using a test mariadb container, the new metrics will appear as

mysql_mysql_innodb_index_stats{database_name="mysql",index_name="PRIMARY",stat_name="n_diff_pfx01",table_name="gtid_slave_pos"} 0
mysql_mysql_innodb_index_stats{database_name="mysql",index_name="PRIMARY",stat_name="n_diff_pfx02",table_name="gtid_slave_pos"} 0
mysql_mysql_innodb_index_stats{database_name="mysql",index_name="PRIMARY",stat_name="n_leaf_pages",table_name="gtid_slave_pos"} 1
mysql_mysql_innodb_index_stats{database_name="mysql",index_name="PRIMARY",stat_name="size",table_name="gtid_slave_pos"} 1
mysql_mysql_innodb_table_stats_clustered_index_size{database_name="mysql",table_name="gtid_slave_pos"} 1
mysql_mysql_innodb_table_stats_n_rows{database_name="mysql",table_name="gtid_slave_pos"} 0
mysql_mysql_innodb_table_stats_sum_of_other_index_sizes{database_name="mysql",table_name="gtid_slave_pos"} 0

@pgporada pgporada force-pushed the collect-innodb-table-and-index-stats branch 2 times, most recently from fb765d9 to c331ae5 Compare February 5, 2021 19:18
@pgporada
Copy link
Author

pgporada commented Feb 5, 2021

Fixes #389

@guidoiaquinti
Copy link
Contributor

Nice work! 👏

In a future iteration, what do you think about adding CLI flags to be able to specify which schema and table to watch? In a big deployment exporting metrics for all database/tables can be expensive.

@pgporada
Copy link
Author

pgporada commented Feb 10, 2021

I think that would be wise to add to this PR. When I first started on this work I knew 0 golang. I now know 1 golang and can probably suss it out.

@mdkent
Copy link

mdkent commented Feb 26, 2021

@pgporada I'm curious how you're updating these stats, are you calling ANALYZE TABLE on a regular cadence or do you just have enough row churn that they get regular updates?

Per https://mariadb.com/kb/en/innodb-system-variables/#innodb_stats_auto_recalc you need ~10% of the rows to get touched for a stats refresh.

@pgporada
Copy link
Author

pgporada commented Feb 26, 2021

@mdkent
The Boulder CA software has very high row churn when updating certificate status information for 200+ million active TLS certificates.

I've not had a chance to pick this back up since I stated that I would try 16 days ago.

Copy link
Member

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

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

The problem with these generic stats dumps is that they're not useful without some extended documentation/help.

In Prometheus, we tend to avoid generic data dumps. Rather, we create opinionated names/mappings so that the end users doesn't have as much work to do in order to understand the meaning of the metrics.

collector/mysql_innodb_index_stats.go Outdated Show resolved Hide resolved
collector/mysql_innodb_index_stats.go Outdated Show resolved Hide resolved
@pgporada pgporada force-pushed the collect-innodb-table-and-index-stats branch from 3689c1c to 1f55bc3 Compare January 19, 2023 17:29
@pgporada
Copy link
Author

pgporada commented Jan 19, 2023

The problem with these generic stats dumps is that they're not useful without some extended documentation/help.

@SuperQ Where should I do that, in the README.md or in the specific .go files?

The mysql-server:5.7 broken test seems unrelated to this change fwiw.

@pgporada pgporada requested a review from SuperQ January 30, 2023 18:09
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