This article is half-done without your Comment! *** Please share your thoughts via Comment ***
Microsoft SQL Server Profiler is one of the important tool which is useful to find different events and statues of the running queries on Microsoft SQL Server.
Do we have anything like SQL Profiler in MySQL?
I have found this question on many forums and many of MySQL professionals are curious about SQL Profiler in MySQL.
MySQL has SQL Profiler which is built into the database server and you can enable/disable via the MySQL client utility.
Before executing any queries you can enable SQL Profiler and it is only for your particular session.
Internally, it creates one profiling table into INFORMATION_SCHEMA database and when you disconnect with MySQL client, it destroys this table.
Enable SQL Profile at session level:
1 |
SET profiling=1; |
Execute sample query:
1 2 |
SELECT *FROM table_one; SELECT *FROM table_two; |
Check the execution time for each query:
1 2 3 4 5 6 7 |
SHOW PROFILES; /*Result*/ Query_ID Duration Query -------------------------------------------------- 1 0.00355325 SELECT *FROM table_one 2 0.00051850 SELECT *FROM table_two |
Check the execution time for second query only:
1 |
SHOW PROFILE FOR QUERY 2; |
Check the CPU information for second query only:
1 |
SHOW PROFILE CPU FOR QUERY 2; |
The Result: