mysql> set profiling = 1; mysql> select count (*) from comment; mysql> select count (*) from message; mysql> show profiles; + ---------- + ------------ + ------------------------- ----- + | Query_ID | Duration | Query | + ---------- + ------------ + ------------------------- ----- + | 1 | 0.00012700 | select count (*) from comment | | 2 | 0.00014200 | select count (*) from message | + ---------- + ------------ + ------------------------- ----- + 2 rows in set (0.00 sec)
mysql> show profile for query 1; + -------------------------------- + ---------- + | Status | Duration | + -------------------------------- + ---------- + | starting | 0.000015 | | checking query cache for query | 0.000021 | | checking permissions | 0.000003 | | Opening tables | 0.000007 | | System lock | 0.000004 | | Table lock | 0.000023 | | init | 0.000005 | | optimizing | 0.000005 | | executing | 0.000025 | | end | 0.000003 | | end | 0.000001 | | query end | 0.000002 | | storing result in query cache | 0.000003 | | freeing items | 0.000003 | | closing tables | 0.000004 | | logging slow query | 0.000002 | | cleaning up | 0.000001 | + -------------------------------- + ---------- + 17 rows in set (0.00 sec)
mysql> set profiling = 1; mysql> set profiling_history_size = 100;
Source: https://habr.com/ru/post/70435/
All Articles