zoukankan      html  css  js  c++  java
  • 黄聪:Mysql5.6缓存命中率

    MySQL缓存命中率,网上说法不一,下面我说下我的看法,大家轻拍:

    总的select查询数等于com_select(没命中) + qcache_hits(命中) + 解析错误的查询。

    再来看看Com_select变量:

    mysql> show global status like 'Com_select';  
    +---------------+-------+  
    | Variable_name | Value |  
    +---------------+-------+  
    | Com_select    | 46    |  
    +---------------+-------+  

    com_select等于qcache_inserts(缓存失效) + qcache_not_cache(没有缓存) + 权限检查错误的查询。

    因此,Mysql的查询缓存命中率 ≈ qcache_hits / (qcache_hits + com_select)

    查询缓存变量:

    mysql> show global status like 'QCache%'  
    +-------------------------+----------+  
    | Variable_name           | Value    |  
    +-------------------------+----------+  
    | Qcache_free_blocks      | 1        |  
    | Qcache_free_memory      | 18856920 |  
    | Qcache_hits             | 3        |  
    | Qcache_inserts          | 20       |  
    | Qcache_lowmem_prunes    | 0        |  
    | Qcache_not_cached       | 26       |  
    | Qcache_queries_in_cache | 0        |  
    | Qcache_total_blocks     | 1        |  
    +-------------------------+----------+ 

    因此本例中的查询缓存命中率 ≈ 3/(3+46) = 6.12%

    查询缓存变量含义:

    Qcache_free_blocks

    目前还处于空闲状态的 Query Cache中内存 Block 数目,数目大说明可能有碎片。FLUSH QUERY CACHE会对缓存中的碎片进行整理,从而得到一个空闲块。

    Qcache_free_memory

    缓存中的空闲内存总量。

    Qcache_hits

    缓存命中次数。

    Qcache_inserts

    缓存失效次数。

    Qcache_lowmem_prunes

    缓存出现内存不足并且必须要进行清理以便为更多查询提供空间的次数。这个数字最好长时间来看;如果这个数字在不断增长,就表示可能碎片非常严重,或者内存很少。(上面的free_blocks和free_memory可以告诉您属于哪种情况)。

    Qcache_not_cached

    不适合进行缓存的查询的数量,通常是由于这些查询不是SELECT语句以及由于query_cache_type设置的不会被Cache的查询。

    Qcache_queries_in_cache

    当前缓存的查询(和响应)的数量。

    Qcache_total_blocks

    缓存中块的数量。
  • 相关阅读:
    ArcGIS API 之 MapPoint & MultiPoint
    前台特效(6) 折叠栏目(动画效果)
    网站开发人员应该知道的61件事[转载]
    前台特效(1)鼠标改变透明度
    php 常用字符编码转换函数整理
    php导入sql文件
    前台特效(3) 编辑表格
    前台特效(2)回到顶部
    时间函数strtotime
    前台特效(4) 悬浮移动窗口(悬浮广告)
  • 原文地址:https://www.cnblogs.com/huangcong/p/5225317.html
Copyright © 2011-2022 走看看