【mysql explain(转)】教程文章相关的互联网学习教程文章

MySQL explain用法

+—-+————-+——-+——+—————+——+———+——+——+——-+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +—-+————-+——-+——+—————+——+———+——+——+——-+ | 1 | SIMPLE | event | ALL | NULL | NULL | NULL | NULL | 13 | | +—-+————-+——-+——+—————+——+———+——+——+——-+ 1 row in set (0.00 sec) 各个属性的含义 ...

MySQL性能分析及explain的使用

key1=.... where key1=1 and key2=2 where key1=3 and key3=3 and key2=2 根据最左原则,这些都是可以使用索引的,如from test where key1=1 order by key3,用explain分析的话,只用到了normal_key索引,但只对where子句起作用,而后面的order by需要排序。 http://database.51cto.com/art/201108/284783.htm MySQL性能分析及explain的使用标签:内容 exp 例子 表示 .com log font extra weight 本文系统来源...

mysql-explain【图】

explain各项字段说明: id: 1 select_type: SIMPLE table: application_user partitions: NULL type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: 1 filtered: 100.00 Extra: NULL 1.id 代表select 语句的编号, 如果是连接查询,表之间是平等关系, select 编号都是1,从1开始. 如果某select中有子查询,则编号递增. 2.select_type 查询类型3.possible_key: 可能用到的索...

mysql查询语句分析 explain用法

http://www.cnitblog.com/aliyiyi08/archive/2008/09/09/48878.html Mysql Explain 详解一.语法explain < table_name >例如: explain select * from t3 where id=3952602;二.explain输出解释+----+-------------+-------+-------+-------------------+---------+---------+-------+------+-------+| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |+----+-------------+-----...

mysql explain中的type列含义和extra列的含义【图】

很多朋友在用mysql进行调优的时候都肯定会用到explain来看select语句的执行情况,这里简单介绍结果中两个列的含义。 1 type列 官方的说法,说这列表示的是&ldquo;访问类型&rdquo;,更通俗一点就是:mysql找到需要的数据行的方式。一下就是从效率最差到最好顺序分别介绍下: All 这个就是所谓的全表扫描,没有用到任何的index,mysql就是从头到尾把整个表遍历一边,找到所需要的数据行。效率是最差的。如下图,这个表中的usertype不是...

mysql 执行计划分析三看, explain,profiling,optimizer_trace【代码】

http://blog.csdn.net/xj626852095/article/details/52767963 step 1 使用explain 查看执行计划, 5.6后可以加参数 explain format=json xxx 输出json格式的信息 step 2 使用profiling详细的列出在每一个步骤消耗的时间,前提是先执行一遍语句。 #打开profiling 的设置 SET profiling = 1; SHOW VARIABLES LIKE ‘%profiling%‘;#查看队列的内容 show profiles; #来查看统计信息 show profile block io,cpu for query 3; s...

MySQL explain 详解

explain命令的使用及相关参数说明。 https://dev.mysql.com/doc/refman/5.7/en/explain-output.html EXPLAIN Output Columns列名说明id 执行编号,标识select所属的行。如果在语句中没子查询或关联查询,只有唯一的select,每行都将显示1。否则,内层的select语句一般会顺序编号,对应于其在原始语句中的位置select_type 显示本行是简单或复杂select。如果查询有任何复杂的子查询,则最外层标记为PRIMARY(DERIVED、UNION、UNION R...

MySQL explain字段解释

ref :对于每个来自于前面的表的行组合,所有有匹配索引值的行将从这张表中读取。如果不能满足只去一行的情况,会使用索引,则使用ref。如果使用的键仅仅匹配少量行,该联接类型是不错的。range :给定范围内的检索,比如 in(xx,xxxx) 或者 betweenindex :该联接类型与ALL相同,除了只有索引树被扫描。这通常比ALL快,因为索引文件通常比数据文件小,一般在使用了覆盖索引优化的情况下使用all: 对于每个来自于先前的表的行组合,进...

MySQL优化—工欲善其事,必先利其器之EXPLAIN【代码】【图】

CREATE TABLE people(id bigint auto_increment primary key,zipcode char(32) not null default ‘‘,address varchar(128) not null default ‘‘,lastname char(64) not null default ‘‘,firstname char(64) not null default ‘‘,birthdate char(10) not null default ‘‘ );CREATE TABLE people_car(people_id bigint,plate_number varchar(16) not null default ‘‘,engine_number varchar(16) not null default ‘‘,l...

浅谈SQL优化入门:2、等值连接和EXPLAIN(MySQL)【代码】【图】

SELECT vend_name, prod_name, prod_price, quantityFROM vendors, products, orderitemsWHERE vendors.vend_id = products.vend_id AND orderitems.prod_id = products.prod_id;//INNER JOIN方式SELECT vend_name, prod_name, prod_price, quantityFROM (vendors INNER JOIN products ON vendors.vend_id = prodcuts.vend_id) INNER JOIN orderitems ON orderitems.prod_id = products.prod_id;其中,WHERE方式...

mysql explain执行计划详解

1)、id列数字越大越先执行,如果说数字一样大,那么就从上往下依次执行,id列为null的就表是这是一个结果集,不需要使用它来进行查询。 2)、select_type列常见的有: A:simple:表示不需要union操作或者不包含子查询的简单select查询。有连接查询时,外层的查询为simple,且只有一个 B:primary:一个需要union操作或者含有子查询的select,位于最外层的单位查询的select_type即为primary。且只有一个 C:union:...

MYSQL explain详解【图】

1. id SELECT识别符。这是SELECT查询序列号。这个不重要,查询序号即为sql语句执行的顺序,看下面这条sql EXPLAIN SELECT * FROM (SELECT* FROMuchome_space LIMIT 10) AS s 它的执行结果为可以看到这时的id变化了 2.select_type select类型,它有以下几种值 2.1 simple 它表示简单的select,没有union和子查询 2.2 primary 最外面的select,在有子查询的语句中,最外面的select查询就是primary,上图中就是这样 2.3 union union语句的...

Mysql Explain 详解

一.语法explain < table_name >例如: explain select * from t3 where id=3952602;二.explain输出解释+----+-------------+-------+-------+-------------------+---------+---------+-------+------+-------+| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |+----+-------------+-------+-------+-------------------+---------+---------+-------+------+-------+1.id 我...

mysql-EXPLAIN【代码】【图】

* from role_permission where role_id = (select id from role where name=‘管理员‘);        DERIVED: DRIVED值用来表示包含在FROM字句的子查询的SELECT,MySQL会递归执行并将结果放到一个临时表中。服务器内部称其“派生表”,因为该临时表是从子查询中派生来的。 explain select role_id from (select * from role_permission) rp       UNION:UNION中第二个或后面的SELECT语句explain select * from role_pe...

mysql性能分析-------profiling和explain【代码】【图】

MySQL5.0.37版本以上支持了Profiling – 官方手册。此工具可用来查询 SQL 会执行多少时间,System lock和Table lock 花多少时间等等,对定位一条语句的 I/O消耗和CPU消耗 非常重要。查看profiling;  select @@profiling; 启动profiling: set @@profiling=1 关闭profiling : set @@profiling=0;sql语句; 1.查看profile记录show profiles; Duration:我需要时间; query:执行的sql语句; 2.查看详情: show profile for query ...

EXPLAIN - 相关标签