纯属自己理解,如有误导概不负责O(∩_∩)O

加索引:

mysql> flush status;
Query OK, 0 rows affected (0.00 sec) mysql> flush tables;
Query OK, 0 rows affected (0.02 sec) mysql> explain select * from userinfo where username='test1'\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: userinfo
type: ref
possible_keys: username
key: username
key_len: 768
ref: const
rows: 1
Extra: Using where
1 row in set (0.00 sec) mysql> show status like 'handler_read%';
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| Handler_read_first | 0 |
| Handler_read_key | 4 |
| Handler_read_last | 0 |
| Handler_read_next | 0 |
| Handler_read_prev | 0 |
| Handler_read_rnd | 0 |
| Handler_read_rnd_next | 0 |
+-----------------------+-------+
7 rows in set (0.00 sec)

删除索引之后:

mysql> flush status;
Query OK, 0 rows affected (0.00 sec) mysql> flush tables;
Query OK, 0 rows affected (0.00 sec) mysql> explain select * from userinfo where username='te
*************************** 1. row *********************
id: 1
select_type: SIMPLE
table: userinfo
type: ALL
possible_keys: NULL
key: NULL
key_len: NULL
ref: NULL
rows: 4
Extra: Using where
1 row in set (0.00 sec) mysql> show status like 'handler_read%';
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| Handler_read_first | 0 |
| Handler_read_key | 2 |
| Handler_read_last | 0 |
| Handler_read_next | 0 |
| Handler_read_prev | 0 |
| Handler_read_rnd | 0 |
| Handler_read_rnd_next | 0 |
+-----------------------+-------+
7 rows in set (0.00 sec)

官方文档对这几个参数的解释:

Handler_read_first[]
  The number of times the first entry in an index was read. If this value is high, it suggests that the server
is doing a lot of full index scans; for example, SELECT col1 FROM foo, assuming that col1is
indexed.

但是我不知道它在值是越大越好还是越小越好?因为即使是从索引中执行一次full索引扫描,也应该快不到哪去。

• Handler_read_key[]
  The number of requests to read a row based on a key. If this value is high, it is a good indication that
your tables are properly indexed for your queries.

肯定是越大越好

• Handler_read_last[]
The number of requests to read the last key in an index. With ORDER BY, the server will issue a first-key
request followed by several next-key requests, whereas with With ORDER BY DESC, the server will issue
a last-key request followed by several previous-key requests. This variable was added in MySQL 5.6..
• Handler_read_next[]
The number of requests to read the next row in key order. This value is incremented if you are querying
an index column with a range constraint or if you are doing an index scan.

貌似也是越小越好,至少官方文档的例子是这样说的:The Handler_read_next[647]value
decreases from 5 to 1, indicating more efficient use of the index

• Handler_read_prev[]
The number of requests to read the previous row in key order. This read method is mainly used to
optimize ORDER BY ... DESC.

主要用于排序,排序肯定消耗资源

• Handler_read_rnd[]
The number of requests to read a row based on a fixed position. This value is high if you are doing a
lot of queries that require sorting of the result. You probably have a lot of queries that require MySQL to
scan entire tables or you have joins that do not use keys properly.

应该和上一个类似。

• Handler_read_rnd_next[]
The number of requests to read the next row in the data file. This value is high if you are doing a lot of
table scans. Generally this suggests that your tables are not properly indexed or that your queries are
not written to take advantage of the indexes you have.

这个涉及到table scans,肯定是越小越好

Mysql之Handler_read%的更多相关文章

  1. Mysql性能优化二

    接上一篇Mysql性能优化一 建立适当的索引 说起提高数据库性能,索引是最物美价廉的东西了.不用加内存,不用改程序,不用调sql,只要执行个正确的'create index',查询速度就可能提高百倍千 ...

  2. mysql 性能优化方向

    国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...

  3. MySQL学习笔记十四:优化(1)

    SQL优化 1.查看各种SQL执行的频率 mysql> show status like 'Com_select';--Com_insert,Com_delete,connections(试图连 ...

  4. [MySQL Reference Manual] 8 优化

    8.优化 8.优化 8.1 优化概述 8.2 优化SQL语句 8.2.1 优化SELECT语句 8.2.1.1 SELECT语句的速度 8.2.1.2 WHERE子句优化 8.2.1.3 Range优 ...

  5. MySQL优化概述

    一. MySQL优化要点 MySQL优化是一门复杂的综合性技术,主要包括: 1 表的设计合理化(符合 3NF,必要时允许数据冗余) 2.1 SQL语句优化(以查询为主) 2.2 适当添加索引(主键索引 ...

  6. mysql 性能优化方案

    网 上有不少MySQL 性能优化方案,不过,mysql的优化同sql server相比,更为麻烦与复杂,同样的设置,在不同的环境下 ,由于内存,访问量,读写频率,数据差异等等情况,可能会出现不同的结果 ...

  7. mysql索引失效

    在做项目的过程中,难免会遇到明明给mysql建立了索引,可是查询还是很缓慢的情况出现,下面我们来具体分析下这种情况出现的原因及解决方法   索引并不是时时都会生效的,比如以下几种情况,将导致索引失效: ...

  8. mysql 性能优化方案1

    网 上有不少mysql 性能优化方案,不过,mysql的优化同sql server相比,更为麻烦与复杂,同样的设置,在不同的环境下 ,由于内存,访问量,读写频率,数据差异等等情况,可能会出现不同的结果 ...

  9. MySql学习(六) —— 数据库优化理论(二) —— 查询优化技术

    逻辑查询优化包括的技术 1)子查询优化  2)视图重写  3)等价谓词重写  4)条件简化  5)外连接消除  6)嵌套连接消除  7)连接消除  8)语义优化 9)非SPJ优化 一.子查询优化 1. ...

随机推荐

  1. 7.Props向子组件传递数据

    组件实例的作用域是孤立的.这意味着不能并且不应该在子组件的模板内直接引用父组件的数据. 可以使用 props 把数据传给子组件. for-child-msg="aaa"  , fo ...

  2. data命令详解

    Linux date命令的用法 在linux shell编程中,经常用到日期的加减运算 以前都是自己通过expr函数计算,很麻烦 其实date命令本身提供了日期的加减运算 非常方便.例如:得到昨天的时 ...

  3. Linux下配置Django_Apache_Mysql环境(CentOS 7.5)

    本文将介绍如何在Linux上部署Django + Mysql + Apache环境.我们知道,Django内置的http服务器只能工作在单线程下,做开发和调试时候是可以的,但是生产环境通常都会有多用户 ...

  4. Robot Framework user guide

    http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html

  5. 【Kafka】搭建和测试等问题

    1.安装启动kafka #跳转到下载目录cd /opt/setup # 下载安装包 wget http://mirror.bit.edu.cn/apache/kafka/0.10.2.0/kafka_ ...

  6. Ubuntu系统里的python

    Ubuntu系统里,默认安装python2.7.x版本的python,直接执行python命令,打开的将是python 2.7.x版本:python3版本的需要自行安装,安装成功后,执行python3 ...

  7. 实验4 —— [bx]和loop的使用

    实验 综合使用 loop.[bx],编写完整汇编程序,实现向内存 b800:07b8 开始的连续 16 个字单元重复填充字数据 0403H. 以下为示例程序: assume cs:code # 1 c ...

  8. ZOJ 2314 (sgu 194) Reactor Cooling (无源汇有上下界最大流)

    题意: 给定n个点和m条边, 每条边有流量上下限[b,c], 求是否存在一种流动方法使得每条边流量在范围内, 而且每个点的流入 = 流出 分析: 无源汇有上下界最大流模板, 记录每个点流的 in 和 ...

  9. 线段树: CDOJ1598-加帕里公园的friends(区间合并,单点更新)

    加帕里公园的friends Time Limit: 3000/1000MS (Java/Others) Memory Limit: 131072/131072KB (Java/Others) 我还有很 ...

  10. 牛客练习赛22 C 简单瞎搞题

    //位运算 // & 都是1 才是 1 // | 都是0 才是0 // ^ 不一样才是1 #include <iostream> #include <cstdio> # ...