您的位置:宽带测速网 > mysql教程 > 如何进行性能分析profiling

如何进行性能分析profiling

2025-06-22 17:05来源:互联网 [ ]

使用mysql自带的工具profiling

1.查看是否打开
mysql> show variables like '%pro%';
+---------------------------+-------+
| Variable_name | Value |
+---------------------------+-------+
| have_profiling| YES|
| profiling | OFF|
| profiling_history_size| 15|
| protocol_version | 10|
| proxy_user||
| slave_compressed_protocol | OFF|
| stored_program_cache | 256|
+---------------------------+-------+
7 rows in set (0.00 sec)

2.默认是关闭的
打开它
setprofiling=1;

3.使用
select * from corp_base_par where res_date=330000 limit 1;

mysql> show profiles;
+----------+------------+-----------------------------------------------------------+
| Query_ID | Duration| Query |
+----------+------------+-----------------------------------------------------------+
|1 | 0.00008975 | set profiling=1 |
|2 | 0.00088450 | select * from corp_base_par where res_date=330000 limit 1 |
+----------+------------+-----------------------------------------------------------+
2 rows in set (0.00 sec)

显示了 这条sql的具体消耗时间