Open profiling, default is not turned on.
set profiling=1;
Execute the SQL statement to parse
select count(1from wechat_employee,Employee;
Show Profiles Table
mysql> show profiles;
Query Result:
+----------+------------+-----------------------------------------------+| Query_ID | Duration | Query |+----------+------------+-----------------------------------------------+| 1 | 0.00072975 | select count(1) from wechat_employee,Employee || 2 | 0.00028450 | set profiling=1 || 3 | 0.00324875 | select count(1) from wechat_employee,Employee |+----------+------------+-----------------------------------------------+
Query Details:
show profile cpu,block io for query 3;
Results:
+--------------------------------+----------+----------+------------+--------------+---------------+| Status | Duration | Cpu_user | Cpu_system | block_ops_in | Block_ops_out |+--------------------------------+----------+----------+------------+--------------+------------ ---+| Starting | 0.000041 | 0.000000 | 0.000000 | 0 | 0 | | Waiting for query Cache lock | 0.000073 | 0.000000 | 0.000000 | 0 | 0 | | Checking query cache for Query | 0.000025 | 0.000000 | 0.000000 | 0 | 0 | | Checking privileges on Cached | 0.000023 | 0.000000 | 0.000000 | 0 | 0 | | Checking Permissions | 0.000018 | 0.000000 | 0.000000 | 0 | 0 | | Checking Permissions | 0.000012 | 0.000000 | 0.000000 | 0 | 0 | | Sending cached result to Clien | 0.003009 | 0.000000 | 0.004000 | 0 | 0 || Logging Slow Query | 0.000032 | 0.000000 | 0.000000 | 0 | 0 | | Cleaning Up | 0.000018 | 0.000000 | 0.000000 | 0 | 0 |+--------------------------------+----------+----------+------------+--------------+---------------+9 rows in Set (0.00 sec)
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Parsing SQL statement execution time and consuming resources using profiles