1.profile available in mysql5.0.37 and above
2. See if profile is available
SELECT @ @profiling;
to see if profile is enabled, and if the PROFILNG value is 0, you can
SET profiling = 1;
enabled
mysql>select Count (*) from roi_summary;
then show Profiles view as follows:
+----------------+------------+----------------------------------+
| query_id | Duration | Query |
+----------------+------------+----------------------------------+
| 1 | 0.00021500 | SELECT @ @profiling |
| 2 | 0.05522700 | Select COUNT (*) from Roi_summary |
+----------------+------------+----------------------------------+
where the statement with ID 5 is the query statement that was just executed
mysql> Show profile for query 2;
analyze its performance
+--------------------------------+----------+
| Status | Duration |
+--------------------------------+----------+
| (initialization) | 0.000004 |
| checking query cache for Query | 0.000044 |
| Opening Tables | 0.000012 |
| System Lock | 0.000017 |
| Table Lock | 0.00003 |
| init | 0.000013 |
| optimizing | 0.000008 |
| statistics | 0.000013 |
| preparing | 0.000011 |
| executing | 0.000006 |
| Sending Data | 0.747313 |
| end | 0.000014 |
| query End | 0.000006 |
| Storing result in query cache | 0.000006 |
| freeing items | 0.000012 |
| closing Tables | 0.000009 |
| logging slow query | 0.000183 |
+--------------------------------+----------+
$ rows in Set (0.00 sec)
#查看cpu IO memory swaps
mysql> Show profile Cpu,block io,memory,swaps for query 2;
Note:
1.profile is a user-level variable and must be re-enabled each time
2. Need to be used in terminal, invalid under phpMyAdmin
Use of profile in MySQL