mysql调优笔记

来源:互联网 发布:晋城行知教育怎么样 编辑:程序博客网 时间:2024/06/01 12:25

实用工具explain:


explain 语句作用:

1.获取表结构信息

2.获取语句的执行计划信息


1.使用explain获取表结构信息

语法:explain|describe|desc table_name[col_name|wild]

wild标识一个模式字符串,能包含sql的%和_通配符

explain ym_account;desc ym_account;

获取表的创建语句:

show create table ym_account;

获取表的状态统计:

show table status from eym_lib where name='ym_account'

获取表上的索引信息:

show index from ym_account;



2.获取sql语句执行计划:

执行计划能做什么:

1、能告诉我们mysql执行sql的流程。

2.、表与表是关联的先后顺序

3、你需要在哪里添加索引,才会使得sql执行的更有效率

4、帮你选择一条系统认为最有的执行路线。


使用explain获取执行计划信息:

EXPLAIN  [SQL语句]