MySQL Cache hit ratio, the online statement is different, below I say my view, everyone tap:
The total number of select queries equals Com_select (dead) + qcache_hits (hit) + Parse error query.
Let's take a look at the Com_select variable:
Mysql>Show Global Status like 'Com_select'; +---------------+-------+ |Variable_name|Value| +---------------+-------+ |Com_select| $ | +---------------+-------+
Com_select equals qcache_inserts (cache invalidation) + Qcache_not_cache (no cache) + Permission check error query.
Therefore, the query cache hit rate for MySQL ≈qcache_hits/(qcache_hits + com_select)
Query Cache variables:
Mysql>Show Global Status like 'qcache%' +-------------------------+----------+ |Variable_name|Value| +-------------------------+----------+ |Qcache_free_blocks| 1 | |Qcache_free_memory| 18856920 | |Qcache_hits| 3 | |Qcache_inserts| - | |Qcache_lowmem_prunes| 0 | |Qcache_not_cached| - | |Qcache_queries_in_cache| 0 | |Qcache_total_blocks| 1 | +-------------------------+----------+
So the query cache hit ratio ≈3/(3+46) = 6.12% in this example
Query cache variable Meaning:
Qcache_free_blocks |
The number of memory blocks in the Query cache, which is still idle, is large, indicating that there may be fragmentation. FLUSH QUERY Cache organizes the fragments in the cache to get a free block. |
Qcache_free_memory |
The total amount of free memory in the cache. |
Qcache_hits |
The number of cache hits. |
Qcache_inserts |
The number of cache failures. |
Qcache_lowmem_prunes |
The number of times that the cache is out of memory and must be cleaned up to provide space for more queries. This number is best seen over a long period of time, and if the number is growing, it can mean that fragmentation is very serious, or that there is little memory. (The Free_blocks and free_memory above can tell you which is the case). |
Qcache_not_cached |
The number of queries that are not appropriate for caching, usually because these queries are not a SELECT statement and are not cached by the cache because of query_cache_type settings. |
Qcache_queries_in_cache |
The number of queries (and responses) currently cached. |
Qcache_total_blocks |
The number of blocks in the cache. |
Bill: Mysql5.6 Cache Hit Ratio