2331321 发表于 2016-11-8 08:55:15

mysql 性能优化常用工具

mysql 性能优化常用工具:

常用性能检测工具
show engine innodbstatus
show full processlist
information_schema.processlist
explain
create table innodb_table_monitor(a int) engine=innodb;
innodb_locks
innodb_lock_wait
innodb_trx
zabbix监控
pt-tools 工具


性能优化的两种方式:
1.执行计划的解读

1
2
3
4
5
6
mysql> explain    select * from mysql.user;
+----+-------------+-------+------+---------------+------+---------+------+------+-------+
| id | select_type | table | type | possible_keys | key| key_len | ref| rows | Extra |
+----+-------------+-------+------+---------------+------+---------+------+------+-------+
|1 | SIMPLE      | user| ALL| NULL          | NULL | NULL    | NULL |   11 | NULL|
+----+-------------+-------+------+---------------+------+---------+------+------+-------+




explain:重要的列解释:
select_type:查询类型
(
simple:简单的查询,没有union,子查询。
primary:外面的select,在有子查询的语句中,最外面的select查询就是primary
)

type:访问类型,表的访问方式
(
const/system:唯一键查找或者主键查找(=)
ref:非唯一索引(=)
range:范围查找,>,<,>=,<=,like 'dddd%',in('',''),between and
eq_ref:两表连接时,右边表的连接字段是唯一键或者主键时出现此访问方式
index:全索引扫描
all:全表扫描
)

ref:进行索引比较的列或者常量
rows:这个数表示mysql要遍历多少数据才能找到,在innodb上是不准确的。

Extra:
(Using where,Using temporary,Using filesort,
Using index,
Using join buffer,
Impossible where)
explain相关解释

页: [1]
查看完整版本: mysql 性能优化常用工具