Mysql之Handler_read%
纯属自己理解,如有误导概不负责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%的更多相关文章
- Mysql性能优化二
接上一篇Mysql性能优化一 建立适当的索引 说起提高数据库性能,索引是最物美价廉的东西了.不用加内存,不用改程序,不用调sql,只要执行个正确的'create index',查询速度就可能提高百倍千 ...
- mysql 性能优化方向
国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...
- MySQL学习笔记十四:优化(1)
SQL优化 1.查看各种SQL执行的频率 mysql> show status like 'Com_select';--Com_insert,Com_delete,connections(试图连 ...
- [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优 ...
- MySQL优化概述
一. MySQL优化要点 MySQL优化是一门复杂的综合性技术,主要包括: 1 表的设计合理化(符合 3NF,必要时允许数据冗余) 2.1 SQL语句优化(以查询为主) 2.2 适当添加索引(主键索引 ...
- mysql 性能优化方案
网 上有不少MySQL 性能优化方案,不过,mysql的优化同sql server相比,更为麻烦与复杂,同样的设置,在不同的环境下 ,由于内存,访问量,读写频率,数据差异等等情况,可能会出现不同的结果 ...
- mysql索引失效
在做项目的过程中,难免会遇到明明给mysql建立了索引,可是查询还是很缓慢的情况出现,下面我们来具体分析下这种情况出现的原因及解决方法 索引并不是时时都会生效的,比如以下几种情况,将导致索引失效: ...
- mysql 性能优化方案1
网 上有不少mysql 性能优化方案,不过,mysql的优化同sql server相比,更为麻烦与复杂,同样的设置,在不同的环境下 ,由于内存,访问量,读写频率,数据差异等等情况,可能会出现不同的结果 ...
- MySql学习(六) —— 数据库优化理论(二) —— 查询优化技术
逻辑查询优化包括的技术 1)子查询优化 2)视图重写 3)等价谓词重写 4)条件简化 5)外连接消除 6)嵌套连接消除 7)连接消除 8)语义优化 9)非SPJ优化 一.子查询优化 1. ...
随机推荐
- python 嵌套作用域 闭包函数
#闭包函数 def multiplier(factor): def multiplyByFactory(number): return number*factor return multiplyByF ...
- shell脚本,awk在需要的行上打打印空行。
注解: 判断每行中是否包含字母a,包含了,就将$1的值赋值给变量a,然后判断变量a是否存在,存在打印一个空行,在将变量的值使用空变量b赋值,最后在打印输出. 结果就是在包含有字符a的行上打印一个空行.
- sql*plus常用指令介紹
sql*plus常用指令介紹 1.用set指令來設定SQL*Plus的環境參數值 格式: Set 環境參數名 環境參數值 ex:set feedback on set feedback 8.用show ...
- 功能强大的CURL
linux下的curl,有着非同一般的魔力,有人称它为下载工具,我更倾向于叫它“文件传输工具”因为它好像无所不能.从常见的 FTP, HTTP, TELNET, 等协议,还支持代理服务器,cook ...
- 初涉网络流[EK&dinic]
主要还是板子 Edmonds-Karp 从S开始bfs,直到找到一条到达T的路径后将该路径增广,并重复这一过程. 在处理过程中,为了应对“找到的一条路径把其他路径堵塞”的情况,采用了建反向弧的方式来实 ...
- mysql 备份 常用脚本
全备: innobackupex --defaults-file=/data/mysql3316/my3316.cnf --user=root --password=mysqlpass /data/b ...
- linux下jdk安装步骤
1. 登录Linux,切换到root用户 su root 获取root用户权限,当前工作目录不变(需要root密码) 或 sudo -i 不需要root密码直接切换成root(需要当前用户密码) 2. ...
- Vim编辑器基础
Vim编辑器基础 vi:Visual Interface vim:VI iMproved Vim模式 1.编辑模式(命令模式) 只能下达命令,不能键入字符 2.输入模式 键入字符 3.末行模式 左下角 ...
- springBoot 集成swagger2.9.2
加依赖 <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui --> <dependen ...
- python有三元运算符吗
所属网站分类: python基础 > 语法,变量,运算符 作者:goodbody 链接: http://www.pythonheidong.com/blog/article/12/ 来源:pyt ...