Created
June 7, 2011 18:41
-
-
Save sabate/1012853 to your computer and use it in GitHub Desktop.
MySQL Profiler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql> DESC City; | |
+-------------+----------+------+-----+---------+----------------+ | |
| Field | Type | Null | Key | Default | Extra | | |
+-------------+----------+------+-----+---------+----------------+ | |
| ID | int(11) | NO | PRI | NULL | auto_increment | | |
| Name | char(35) | NO | | | | | |
| CountryCode | char(3) | NO | | | | | |
| District | char(20) | NO | | | | | |
| Population | int(11) | NO | | 0 | | | |
+-------------+----------+------+-----+---------+----------------+ | |
5 rows in set (0.00 sec) | |
mysql> SET PROFILING = 1; | |
Query OK, 0 rows affected (0.00 sec) | |
mysql> SELECT ID, Name, Population FROM City ORDER BY Name DESC; | |
... | |
| 2760 | Aba | 298900 | | |
| 3318 | Aalborg | 161161 | | |
| 3097 | Aachen | 243825 | | |
| 670 | A Coruña (La Coruña) | 243402 | | |
+------+------------------------------------+------------+ | |
4079 rows in set (0.03 sec) | |
mysql> SET PROFILING = 0; | |
Query OK, 0 rows affected (0.00 sec) | |
mysql> SHOW PROFILES; | |
+----------+------------+----------------------------------------------------------+ | |
| Query_ID | Duration | Query | |
| | |
+----------+------------+----------------------------------------------------------+ | |
| 1 | 0.02274025 | SELECT ID, Name, Population FROM City ORDER | |
BY Name DESC | | |
+----------+------------+----------------------------------------------------------+ | |
1 row in set (0.00 sec) | |
mysql> SHOW PROFILE FOR QUERY 1; | |
+----------------------+----------+ | |
| Status | Duration | | |
+----------------------+----------+ | |
| starting | 0.000056 | | |
| checking permissions | 0.000007 | | |
| Opening tables | 0.000018 | | |
| System lock | 0.000009 | | |
| init | 0.000014 | | |
| optimizing | 0.000003 | | |
| statistics | 0.000008 | | |
| preparing | 0.000008 | | |
| executing | 0.000002 | | |
| Sorting result | 0.020042 | | |
| Sending data | 0.002536 | | |
| end | 0.000006 | | |
| query end | 0.000003 | | |
| closing tables | 0.000009 | | |
| freeing items | 0.000012 | | |
| logging slow query | 0.000002 | | |
| cleaning up | 0.000007 | | |
+----------------------+----------+ | |
17 rows in set (0.00 sec) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment