Skip to content

Wrong table cache hit rate calculation #548

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

Closed
MichaIng opened this issue Mar 13, 2021 · 2 comments
Closed

Wrong table cache hit rate calculation #548

MichaIng opened this issue Mar 13, 2021 · 2 comments
Assignees

Comments

@MichaIng
Copy link
Contributor

Based on https://github.com/major/MySQLTuner-perl/blob/master/mysqltuner.pl#L2706 the table cache hit rate is currently calculated as ratio of Open_tables and Opened_Tables, hence the currently opened non-temporary tables and the overall opened tables. But this does not represent that cache hit rate where the table_open_cache recommended should be based on, does it?

There are two stats for table cache hits and misses which seem to be the correct ones here:

MariaDB [(none)]> show global status like 'Table_open_cache_%';
+-----------------------------------+----------+
| Variable_name                     | Value    |
+-----------------------------------+----------+
| Table_open_cache_active_instances | 1        |
| Table_open_cache_hits             | 22555304 |
| Table_open_cache_misses           | 2866     |
| Table_open_cache_overflows        | 0        |
+-----------------------------------+----------+

=>

int( $mystat{'Table_open_cache_hits'} * 100 / ( $mystat{'Table_open_cache_hits'} + $mystat{'Table_open_cache_misses'} ) );
@MichaIng
Copy link
Contributor Author

Many thanks for 2079639, it works as expected here now.

Btw, I just verified that these variables are the same on MySQL, but they have been introduced with v5.6: https://dev.mysql.com/doc/refman/5.6/en/added-deprecated-removed.html

jmrenouard added a commit that referenced this issue Jul 15, 2021
Wrong table cache hit rate calculation #548
jmrenouard added a commit that referenced this issue Jul 15, 2021
Wrong table cache hit rate calculation #548
@sbrowne-godaddy
Copy link

Whilst a little late, this now breaks the math if Table_open_cache_hits or Table_open_cache_misses isn't present in the hash. The items the math depends upon are no longer having their existence tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants