http://blog.csdn.net/k_scott/article/details/8804384
1. First check whether the profiling function is turned on
[SQL]View PlainCopy
- SHOW VARIABLES like '%pro% ';
Or
[SQL]View PlainCopy
- SELECT @ @profiling;
2. Open Profiling
[SQL]View PlainCopy
- SET profiling=1;
3. Execute SQL statements
For example:
[SQL]View PlainCopy
- select
- table_schema as ' Db name ',
- round ( sum ( data_length + index_length ) / 1024 / 1024, 3 ) as ' db size (MB) ',
- round ( sum ( data_free ) / 1024 / 1024, 3 ) as ' free space (MB) '
- from information_schema.tables
- group by table_schema ;
4. View Results
[SQL]View PlainCopy
- SHOW profiles;
[SQL]View PlainCopy
- SHOW profile all for QUERY 94;
94 is the query ID number.
SHOW Profiles Syntax:
[SQL]View PlainCopy
- SHOW profile [Type [, type] ...]
- [ForQUERY N]
- [LIMIT row_count [offset offset]]
- Type
- All
- | BLOCK IO
- | CONTEXT Switches
- | Cpu
- | Ipc
- | MEMORY
- | PAGE faults
- | SOURCE
- | SWAPS
MySQL find SQL time-consuming bottleneck SHOW profiles