Mysql自带profiling性能分析工具
1. show variables like '%profiling%';(查看profiling信息) www.2cto.com
![](http://up.2cto.com/2012/1110/20121110113606224.jpg)
2. set profiling=1;(开启profiling)
![](http://up.2cto.com/2012/1110/20121110113606673.jpg)
3. 执行SQL查询
例:select goods_name from ecs_goods where goods_id <5000;
show profiles;
![](http://up.2cto.com/2012/1110/20121110113607190.jpg)
4. show profile for query 4;
![](http://up.2cto.com/2012/1110/20121110113607499.jpg)
show profile 的格式如下:
SHOW PROFILE [type [, type] ... ]
[FOR QUERY n]
[LIMIT row_count [OFFSET offset]]
type:
ALL
| BLOCK IO
| CONTEXT SWITCHES
| CPU
| IPC
| MEMORY
| PAGE FAULTS
| SOURCE
| SWAPS