使用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.默认是关闭的
打开它
set profiling=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的具体消耗时间
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30127122/viewspace-2095060/
,如需转载,请注明出处,否则将追究法律责任。