How can I see how long statements take to execute on the MySQL command line?


For every single statement on MySQL command line, it shows the exact time to execute the specific statement.

Let us first create a table −

mysql> create table DemoTable1589
   -> (
   -> EmployeeId int,
   -> EmployeeName varchar(20)
   -> );
Query OK, 0 rows affected (0.56 sec)

Insert some records in the table using insert command −

mysql> insert into DemoTable1589 values(101,'Sam');
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable1589 values(102,'Bob');
Query OK, 1 row affected (0.18 sec)
mysql> insert into DemoTable1589 values(103,'David');
Query OK, 1 row affected (0.16 sec)

Display all records from the table using select statement −

mysql> select * from DemoTable1589;

This will produce the following output −

+------------+--------------+
| EmployeeId | EmployeeName |
+------------+--------------+
|        101 | Sam          |
|        102 | Bob          |
|        103 | David        |
+------------+--------------+

3 rows in set (0.04 sec)

Updated on: 16-Dec-2019

87 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements