explain mysql语句_explainmysql查询语句_MySQL

MySQLexplain

bitsCN.com

explain mysql查询语句

Explain SQL语句性能测试返回值的具体含义:

Sql代码

mysql> explain SELECT `content_id` , `content_old_id`, `content_hasimg` ,`content_time_update`, `content_title_long`, `vhost_content`.`site_id`, `site_domain`, `site_name`, `site_state` FROM `vhost_content` LEFT JOIN `vhost_site` ON `vhost_content`.`site_id` = `vhost_site`.`site_id` WHERE `content_effect` = 1 AND `content_audit` = 1 AND `content_publish` = 1 AND `content_time_update` >= '2012-12-16' AND `vhost_content`.`site_id` LIKE '001001001%' AND 1=1 ORDER BY `content_time_update` desc LIMIT 0 , 25;

+----+-------------+---------------+-------+--------------------------------------------------------------------------+------------------+---------+-------------------------------+------+-----------------------------+

| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |

+----+-------------+---------------+-------+--------------------------------------------------------------------------+------------------+---------+-------------------------------+------+-----------------------------+

| 1 | SIMPLE | vhost_content | range | idx_content_site,Refvhost_site483,idx_content_uptime,idx_content_publish | idx_content_site | 55 | NULL | 198 | Using where; Using filesort |

| 1 | SIMPLE | vhost_site | ref | PRIMARY | PRIMARY | 54 | vhostdb.vhost_content.site_id | 1 | |

+----+-------------+---------------+-------+--------------------------------------------------------------------------+------------------+---------+-------------------------------+------+-----------------------------+

Table: 显示该语句涉及数据库表

Type: 这列很重要, 显示了该连接使用了哪种类别, 有无使用索引,反应语句的质量 。结果值从好到坏依次是 : system > const > eq_ref > ref > fulltext > ref_or_null > index_merge > unique_subquery > index_subquery > range > index > ALL , 一般来说,得保证查询至少达到range级别, 最好能到达ref级别, 否则就可能出现性能问题。

Possible_key : 指出mysql能使用哪个索引在该表中找到行

Key: 显示mysql实际使用的键(索引), 如果没有选择索引, 键是null。

Key_len : 显示mysql决定使用的键长度。 如果是null, 则长度为null,在不损失精确性的情况下, 长度越短越好。

Ref: 显示使用哪个列或常数与key一起从表中选择行。

Rows: 显示mysql认为它执行查询时必须检查的行数。

Extra : 包含mysql解决查询的详细信息。

bitsCN.com

本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉

本文系统来源:php中文网

TAG标签:mysql

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值