问题描述
我在MySQL数据库中的information_schema 库里的GLOBAL_VARIABLES. GLOBAL_STATUS表可以取出来好多数据,比如:•key_buffer_size•key_cache_block_size•query_cache_limit•query_cache_size...等等 可是我不知道怎么计算Key Hitrate ,Key Buffer Used, Query Cache Hitrate 希望有人可以帮到我.
解决方案
mysql> show global status like ‘qcache%‘;+-------------------------------+-----------------+| Variable_name | Value |+-------------------------------+-----------------+| Qcache_free_blocks | 22756 || Qcache_free_memory | 76764704 || Qcache_hits | 213028692 || Qcache_inserts | 208894227 || Qcache_lowmem_prunes | 4010916 || Qcache_not_cached | 13385031 || Qcache_queries_in_cache | 43560 || Qcache_total_blocks | 111212 |+-------------------------------+-----------------+Qcache_inserts应该是没命中之后插入到qcache里的次数查询缓存命中率 = (Qcache_hits - Qcache_inserts) / Qcache_hits * 100%Key Buffer Used就是key buffer已使用的大小嚒。。。Key Hit rate就是索引的命中率么。。mysql> show global status like ‘key_read%‘;+------------------------+-------------+| Variable_name | Value |+------------------------+-------------+| Key_read_requests| 27813678764 || Key_reads | 6798830 |+------------------------+-------------+一共有27813678764个索引读取请求,有6798830个请求在内存中没有找到直接从硬盘读取索引,计算索引未命中缓存的概率:key_cache_miss_rate = Key_reads / Key_read_requests * 100%hit rate应该就是1-key_cache_miss_rate 吧。。。