|
mysql> SELECT @@profiling;
+-------------+
| @@profiling |
+-------------+
| 0 |
+-------------+
1 row in set (0.00 sec)
mysql> SET profiling = 1;
Query OK, 0 rows affected (0.00 sec)
-------
查询...
select ....
update...
----
mysql> show profiles;
+----------+------------+-------------------------------------------------------------+
| Query_ID | Duration | Query |
+----------+------------+-------------------------------------------------------------+
| 1 | 0.00297000 | show databases |
| 2 | 0.00073400 | SELECT DATABASE() |
| 3 | 0.00076800 | select * from DBA_TEST |
| 4 | 0.00073900 | SELECT DATABASE() |
| 5 | 0.00127800 | SHOW TABLES |
| 6 | 0.00278500 | SELECT * FROM test |
| 7 | 0.00131100 | select status,count(*) from test_profiling group by status |
+----------+------------+-------------------------------------------------------------+
7 rows in set (0.00 sec)
mysql> show profile cpu, block io for query 6;
+--------------------+----------+----------+------------+--------------+---------------+
| Status | Duration | CPU_user | CPU_system | Block_ops_in | Block_ops_out |
+--------------------+----------+----------+------------+--------------+---------------+
| starting | 0.000341 | 0.000000 | 0.000000 | 0 | 0 |
| Opening tables | 0.000240 | 0.000000 | 0.000000 | 0 | 0 |
| System lock | 0.000038 | 0.000000 | 0.000000 | 0 | 0 |
| Table lock | 0.000045 | 0.000000 | 0.000000 | 0 | 0 |
| init | 0.000183 | 0.000000 | 0.000000 | 0 | 0 |
| optimizing | 0.000007 | 0.000000 | 0.000000 | 0 | 0 |
| statistics | 0.000116 | 0.000000 | 0.000000 | 0 | 0 |
| preparing | 0.000042 | 0.000000 | 0.000000 | 0 | 0 |
| executing | 0.000034 | 0.000000 | 0.000000 | 0 | 0 |
| Sending data | 0.001563 | 0.000000 | 0.000000 | 0 | 0 |
| end | 0.000013 | 0.000000 | 0.000000 | 0 | 0 |
| query end | 0.000005 | 0.000000 | 0.000000 | 0 | 0 |
| freeing items | 0.000147 | 0.000000 | 0.000000 | 0 | 0 |
| logging slow query | 0.000005 | 0.000000 | 0.000000 | 0 | 0 |
| cleaning up | 0.000006 | 0.000000 | 0.000000 | 0 | 0 |
+--------------------+----------+----------+------------+--------------+---------------+
15 rows in set (0.00 sec) |
|