MySql如何计算Key Hitrate ,Key Buffer Used, Query Cache Hitrate??请问.

问题描述

我在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 吧。。。

时间: 2024-08-24 21:17:50

MySql如何计算Key Hitrate ,Key Buffer Used, Query Cache Hitrate??请问.的相关文章

转贴一个有关MYSQL的文章.E文的.MySQLs Query Cache

cache|mysql A typical scenarioBoss: Our new website is crawling! How can it be, we have four state-of-the-art web servers - what's the problem?You: Well, the web servers are fine - it's the database server that's struggling.Boss: What? You told me th

MySQL SQL 分析 - 参数化查询 vs query cache 功能

query cache,  mysql 5 开始附带的一个功能, 与引擎无关, 只与数据查询语法相关.   测试描述: 当前使用中是 MySQL-5.6.14 Linux RHEL6  64 位系统产生环境,  使用 INNODB 引擎, 分配 innodb 2g 内存空间   [root@TiYanPlat ~]# uname -a Linux TiYanPlat 2.6.32-358.el6.x86_64 #1 SMP Tue Jan 29 11:47:41 EST 2013 x86_64

Mysql中对primary key一点选择改变

在5.1.46中优化器在对primary key的选择上做了一点改动: Performance: While looking for the shortest index for a covering index scan, the optimizer did not consider the full row length for a clustered primary key, as in InnoDB. Secondary covering indexes will now be pref

Using INSERT IGNORE with MySQL to prevent duplicate key errors

An error will occur when inserting a new record in MySQL if the primary key specified in the insert query already exists. Using the "IGNORE" keyword prevents errors from occuring and other queries are still able to be run. Why? Although you shou

简单分析MySQL中的primary key功能_Mysql

在5.1.46中优化器在对primary key的选择上做了一点改动: Performance: While looking for the shortest index for a covering index scan, the optimizer did not consider the full row length for a clustered primary key, as in InnoDB. Secondary covering indexes will now be pref

MySQL使用query cache缓存简单使用教程

1. query cache的key是sql字符串,并且要求精确匹配:大小写不一样或者多了一个空格,都会导致cache miss 2. query cache直接把用户输入的原始sql作为key, 不是把解析后或优化后的sql作为key,也不会把其中的子查询独立缓存 2. 存储过程中的sql结果不会被缓存 3. 如果一个sql会产生不确定的结果(即使表中数据没有变化也会不确定),比如select now(), MySQL就不会缓存它的结果 4. 只要表中数据有任何变化,就会导致本表相关的所有qu

MySQL · 源码分析 · Query Cache内部剖析

Query Cache背景 Query Cache在其他数据库里面也称为结果集缓存.顾名思义,它的目的是将SELECT语句与其返回结果缓存到Query Cache中,如果重复执行相同的SELECT语句的话,我们可以跳过MySQL的解析.优化.执行阶段,将SELECT的查询结果直接返回到客户端,加速SELECT语句的执行. Query Cache中的主要数据结构 Query_cache 对整个Query Cache进行管理,负责提供接口供Server调用. Query_cache_block Qu

MySQL的Query Cache原理分析_Mysql

原理 QueryCache(下面简称QC)是根据SQL语句来cache的.一个SQL查询如果以select开头,那么MySQL服务器将尝试对其使用QC.每个Cache都是以SQL文本作为key来存的.在应用QC之前,SQL文本不会被作任何处理.也就是说,两个SQL语句,只要相差哪怕是一个字符(例如大小写不一样:多一个空格等),那么这两个SQL将使用不同的一个CACHE. 不过SQL文本有可能会被客户端做一些处理.例如在官方的命令行客户端里,在发送SQL给服务器之前,会做如下处理:  过滤所有注释

mysql query cache用法与性能详细介绍

mysql Query Cache 默认为打开.从某种程度可以提高查询的效果,但是未必是最优的解决方案,如果有的大量的修改和查询时,由于修改造成的cache失效,会给服务器造成很大的开销,可以通过query_cache_type[0(OFF)1(ON)2(DEMAND)]来控制缓存的开关. 需要注意的是mysql query cache 是对大小写敏感的,因为Query Cache 在内存中是以 HASH 结构来进行映射,HASH 算法基础就是组成 SQL 语句的字符,所以 任何sql语句的改变