Skip to content
Advertisement

How to know what the select query took time?

I have 4 queries and I want to compare the time between them, Is there any command to show the time taken for every query?

Advertisement

Answer

You have can use SHOW PROFILE Statement.

Enable it by using:

SET profiling = 1;

For example, I executed some queries as below:

mysql> CREATE TABLE T1 (id INT);

mysql> use gesti;

mysql> show tables;

mysql> select * from orders limit 10;


mysql> show profiles;
+----------+------------+-------------------------------+
| Query_ID | Duration   | Query                         |
+----------+------------+-------------------------------+
|        1 | 0.38483575 | CREATE TABLE T1 (id INT)      |
|        2 | 0.00039525 | SELECT DATABASE()             |
|        3 | 0.00604350 | show tables                   |
|        4 | 0.00075625 | select * from orders limit 10 |
+----------+------------+-------------------------------+
4 rows in set, 1 warning (0.00 sec)

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement