qcache_inserts com_select 与缓存命中率

来源:互联网 发布:大连软件发展状况 编辑:程序博客网 时间:2024/05/17 04:58

高性能MySQL这本书中关于查询缓存有一段这样的描述:

 

Cache invalidations can happen because of fragmentation, insufficient memory, or
data modifications. If you have allocated enough memory to the cache and tuned the
query_cache_min_res_unit value properly, most cache invalidations should be due to
data modifications. You can see how many queries have modified data by examining
the Com_* status variables (Com_update, Com_delete, and so forth), and you can see
how many queries have been invalidated due to low memory by checking the Qcache_
lowmem_prunes status variable.

 

既然没有命中,肯定要有com_select,读之后要加到缓存中,要有qcache_inserts,既然是这样,我不解的是应该一次com_select就对应一次qcache_inserts阿,为什么qcache_inserts会比com_select小的多呢?原来是这样的:

 

The total number of SELECT queries is given by this formula:

Com_select + Qcache_hits+ queries with errors found by parser

 

The Com_select value is given by this formula:

Qcache_inserts + Qcache_not_cached + queries with errors found during the column-privileges check

 

总的select查询数等于com_select(没命中) + qcache_hits(命中) + 解析错误的,其中的com_select等于qcache_inserts(失效) + qcache_not_cache + 权限检查错误的。也就是说qcache_inserts这个计数不是表示没被缓存而进行的读,而是缓存失效而进行的读,没被缓存和缓存失效是两个概念,分别计数,但都会引起com_select。

 

参考:

http://dev.mysql.com/doc/refman/5.0/en/query-cache-status-and-maintenance.html

http://www.wzsky.net/html/article/php/php2/15874.html

 

还是要认真读官方文档阿。

0 0
原创粉丝点击