mysql> set profiling=1;
#開啟
mysql> select * from li limit 2;
+--------+----------+
| id | name |
+--------+----------+
| 1458 | hello |
| 1457 | world |
+--------+----------+
mysql> show profiles;
+--------------+----------------+------------------------------+
| Query_ID | Duration | Query |
+--------------+----------------+------------------------------+
| 1 | 0.00013200 | SELECT DATABASE() |
| 2 | 0.00044100 | select * from li limit 2 |
+--------------+----------------+------------------------------+
mysql> show profile for query 2;
+---------------------------+--------------+
| Status | Duration |
+---------------------------+--------------+
| starting | 0.000058 |
| Opening tables | 0.000011 |
| System lock | 0.000007 |
| Table lock | 0.000014 |
| init | 0.000027 |
| optimizing | 0.000003 |
| statistics | 0.000010 |
| preparing | 0.000010 |
| executing | 0.000007 |
| Sending data | 0.000068 |
| end | 0.000003 |
| query end | 0.000002 |
| freeing items | 0.000208 |
| logging slow query | 0.000002 |
| logging slow query | 0.000009 |
| cleaning up | 0.000002 |
+---------------------------+--------------+
#此外還有2個(gè)語句可以查看更多信息。
show profile cpu for query 2;
show profile IPC for query 2;