免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2827 | 回复: 0
打印 上一主题 下一主题

Mysql管理必备工具Maatkit详解之八(mk-visual-explain) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-02-23 11:27 |只看该作者 |倒序浏览

Mysql管理必备工具Maatkit详解之八(mk-visual-explain)
2009年05月26日 作者: 大头刚 
mk-visual-explain - 格式化mysql执行计划输出。安装方法可以参考
这里

Mysql默认的执行计划输出类似如下:
mysql> explain select count(*) from test a,test2 b where a.id100 and b.id>160 and a.id=b.id;
+----+-------------+-------+--------+---------------+---------+---------+----------------+------+-------------+
| id | select_type | table | type   | possible_keys | key     | key_len | ref            | rows | Extra       |
+----+-------------+-------+--------+---------------+---------+---------+----------------+------+-------------+
|  1 | SIMPLE      | b     | range  | uid           | id     | 4       | NULL           |   30 | Using where |
|  1 | SIMPLE      | a     | eq_ref | PRIMARY       | PRIMARY | 4       | b.uid |    1 | Using index |
+----+-------------+-------+--------+---------------+---------+---------+----------------+------+-------------+
2 rows in set (0.00 sec)
使人觉得很单一、没有层次感,那么可以使用这个工具来转化成树状结构。
mysql> pager mk-visual-explain;
PAGER set to 'mk-visual-explain'
mysql> explain select count(*) from test a,test2 b where a.id100 and b.id>160 and a.id=b.id;
JOIN
+- Unique index lookup
|  key            a->PRIMARY
|  possible_keys  PRIMARY
|  key_len        4
|  ref            b.id
|  rows           1
+- Filter with WHERE
   +- Bookmark lookup
      +- Table
      |  table          b
      |  possible_keys  id
      +- Index range scan
         key            b->id
         possible_keys  id
         key_len        4
         rows           30
2 rows in set (0.00 sec)
是否觉得舒服多了?当然实质的内容还是一样的,选择怎么输出就看自己的喜好了。


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/111930/showart_2184880.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP