一、Mysql查询缓存碎片和缓存命中率。
mysql> SHOW STATUS LIKE 'qcache%';
+-------------------------+-----------+
| Variable_name | Value |
+-------------------------+-----------+
| Qcache_free_blocks | 5 |
| Qcache_free_memory | 134176648 |
| Qcache_hits | 110 |
| Qcache_inserts | 245 |
| Qcache_lowmem_prunes | 0 |
| Qcache_not_cached | 7119 |
| Qcache_queries_in_cache | 9 |
| Qcache_total_blocks | 31 |
+-------------------------+-----------+
8 rows in set (0.01 sec)
MySQL 查询缓存变量
变量名
说明
Qcache_free_blocks
缓存中相邻内存块的个数。数目大说明可能有碎片。FLUSH QUERY CACHE 会对缓存中的碎片进行整理,从而得到一个空闲块。
Qcache_free_memory
缓存中的空闲内存。
Qcache_hits
每次查询在缓存中命中时就增大。
Qcache_inserts
每次插入一个查询时就增大。命中次数除以插入次数就是不中比率;用 1 减去这个值就是命中率。在上面