1. 查看是否开启 show variables like 'profiling'; 2. 开启功能 set profiling = on 3. 运行sql #写的尽量耗时的sql,利于分析 select * from xxx group by id%20 order by 5; #show profile 会记录这条sql 4. 查询结果 show profiles 5. 诊断sql #cpu,block io 常用的两个参数 show profile cpu,block io for que…
开启profile优化SQL语句:set profiling=1;执行SQL语句show profiles;show profile for query 2;//根据query_id 查看某个查询的详细时间耗费 SHOW STATUS LIKE 'last_query_cost';//查询上一条语句执行的代价 例: mysql> show profiles;+----------+------------+----------------------------------------+| Qu…
一.SQL 执行时间分析通过找到执行时间长的 SQL 语句,可以直观的发现数据层的效率问题. 1.通过 show processlist 来查看系统的执行情况mysql> show processlist;+----+------+-----------+------+---------+------+-------+------------------+| Id | User | Host | db | Command | Time | State | Info |+----+------+-…