profiling和trace语句使用
来源:互联网 发布:圣塔克拉拉大学 知乎 编辑:程序博客网 时间:2024/06/05 04:22
一,show profile 分析sql性能:
1,环境准备
select @@have_profiling; #查看是否支持
select @@profiling; #查看是否开启
set profiling=1; #默认为0,表示不开启。在session级别开启
2,测试sql
select count(1) from t;
3,查看:
show profiles;#记下目标id
show profile for query ${id};
4, 排序查看:
set @query_id :=6;
select state,sum(duration) as total_r,round(100 * sum(duration)/(select sum(duration) from information_schema.profiling where query_id = @query_id ),2)as pct_r,count(*) as calls,sum(duration) / count(*) as "R/Call" from information_schema.profiling where query_id = @query_id group by state order by total_r desc;
5,单项查看,可以找到具体是哪个硬件消耗最多:
show profile all|cpu|block io|context switch|page faults for query ${id}show
记得关闭:
1,环境准备
select @@have_profiling; #查看是否支持
select @@profiling; #查看是否开启
set profiling=1; #默认为0,表示不开启。在session级别开启
2,测试sql
select count(1) from t;
3,查看:
show profiles;#记下目标id
show profile for query ${id};
4, 排序查看:
set @query_id :=6;
select state,sum(duration) as total_r,round(100 * sum(duration)/(select sum(duration) from information_schema.profiling where query_id = @query_id ),2)as pct_r,count(*) as calls,sum(duration) / count(*) as "R/Call" from information_schema.profiling where query_id = @query_id group by state order by total_r desc;
5,单项查看,可以找到具体是哪个硬件消耗最多:
show profile all|cpu|block io|context switch|page faults for query ${id}show
记得关闭:
set profiling=0;
二,trace命令使用:
1,打开并设置tarce使用内存的大小。
set optimizer_trace="enabled=on",end_markers_in_json=on; #两个参数都是session级别。
set optimizer_trace_max_mem_size =1000000; #默认16384(16M),不报错则可以不设置。
2,执行sql
select * from t;
3,查看
select * from information_schema.optimizer_trace \G
4,关闭
set optimizer_trace="enabled=off",end_markers_in_json=off;
0 0
- profiling和trace语句使用
- mysql使用Profiling分析query语句,sql语句性能优化
- Mysql使用profiling分析慢sql语句的原因
- 使用trace跟踪sql语句执行计划
- TRACE()语句
- TRACE()语句
- profiling 的使用
- Mysql Profiling的使用
- MySQL Profiling 的使用
- MySQL Profiling 的使用
- MySQL Profiling的使用
- MySQL Profiling 的使用
- SQL TRACE 和 tkprof sql语句分析工具
- SQL TRACE 和 tkprof sql语句分析工具
- 使用SQL TRACE 实用工具和TKPROF
- c#如何使用 Debug 和 Trace 类
- SQL TRACE和TKPROF的使用步骤
- c#如何使用 Debug 和 Trace 类
- Android_Fragment
- PyCharm 2017.1.1 破解
- BZOJ 3224: Tyvj 1728 普通平衡树(替罪羊树)
- css之三栏布局
- MySQL数据库备份还原(基于binlog的增量备份)
- profiling和trace语句使用
- AVAudioplayer时error解决 创建失败
- JDK中的URLConnection参数详解
- kNN(k近邻算法)
- C++第5次实验报告
- 机器人相关的会议期刊
- centOS7系统安装jdk异常报错解决方法
- String.Compare(String, String, StringComparison)方法
- 十字链表