追蹤特定陳述式摘要的所有 Performance Schema 工具。
如果您在 Performance Schema 的 events_statements_summary_by_digest
表格中找到感興趣的陳述式,請指定其 DIGEST
欄位的 MD5 值給此程序,並指示輪詢持續時間和間隔。結果是在該間隔內追蹤的該摘要的所有 Performance Schema 統計資料報告。
此程序還嘗試針對該間隔內最長執行時間的摘要範例執行 EXPLAIN
。由於 Performance Schema 會截斷較長的 SQL_TEXT
值,因此此嘗試可能會失敗。因此,由於剖析錯誤,EXPLAIN
會失敗。
此程序在執行期間會透過操作系統變數 sql_log_bin
的工作階段值來停用二進位記錄。這是一項受限制的操作,因此該程序需要足夠的權限才能設定受限制的工作階段變數。請參閱第 7.1.9.1 節,「系統變數權限」。
in_digest VARCHAR(32)
:要分析的陳述式摘要識別碼。in_runtime INT
:分析要執行的時間長度,以秒為單位。in_interval DECIMAL(2,2)
:嘗試擷取快照的分析間隔,以秒為單位(可以是小數)。in_start_fresh BOOLEAN
:是否在開始前截斷 Performance Schemaevents_statements_history_long
和events_stages_history_long
表格。in_auto_enable BOOLEAN
:是否自動啟用所需的消費者。
mysql> CALL sys.ps_trace_statement_digest('891ec6860f98ba46d89dd20b0c03652c', 10, 0.1, TRUE, TRUE);
+--------------------+
| SUMMARY STATISTICS |
+--------------------+
| SUMMARY STATISTICS |
+--------------------+
1 row in set (9.11 sec)
+------------+-----------+-----------+-----------+---------------+------------+------------+
| executions | exec_time | lock_time | rows_sent | rows_examined | tmp_tables | full_scans |
+------------+-----------+-----------+-----------+---------------+------------+------------+
| 21 | 4.11 ms | 2.00 ms | 0 | 21 | 0 | 0 |
+------------+-----------+-----------+-----------+---------------+------------+------------+
1 row in set (9.11 sec)
+------------------------------------------+-------+-----------+
| event_name | count | latency |
+------------------------------------------+-------+-----------+
| stage/sql/statistics | 16 | 546.92 us |
| stage/sql/freeing items | 18 | 520.11 us |
| stage/sql/init | 51 | 466.80 us |
...
| stage/sql/cleaning up | 18 | 11.92 us |
| stage/sql/executing | 16 | 6.95 us |
+------------------------------------------+-------+-----------+
17 rows in set (9.12 sec)
+---------------------------+
| LONGEST RUNNING STATEMENT |
+---------------------------+
| LONGEST RUNNING STATEMENT |
+---------------------------+
1 row in set (9.16 sec)
+-----------+-----------+-----------+-----------+---------------+------------+-----------+
| thread_id | exec_time | lock_time | rows_sent | rows_examined | tmp_tables | full_scan |
+-----------+-----------+-----------+-----------+---------------+------------+-----------+
| 166646 | 618.43 us | 1.00 ms | 0 | 1 | 0 | 0 |
+-----------+-----------+-----------+-----------+---------------+------------+-----------+
1 row in set (9.16 sec)
# Truncated for clarity...
+-----------------------------------------------------------------+
| sql_text |
+-----------------------------------------------------------------+
| select hibeventhe0_.id as id1382_, hibeventhe0_.createdTime ... |
+-----------------------------------------------------------------+
1 row in set (9.17 sec)
+------------------------------------------+-----------+
| event_name | latency |
+------------------------------------------+-----------+
| stage/sql/init | 8.61 us |
| stage/sql/init | 331.07 ns |
...
| stage/sql/freeing items | 30.46 us |
| stage/sql/cleaning up | 662.13 ns |
+------------------------------------------+-----------+
18 rows in set (9.23 sec)
+----+-------------+--------------+-------+---------------+-----------+---------+-------------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------------+-------+---------------+-----------+---------+-------------+------+-------+
| 1 | SIMPLE | hibeventhe0_ | const | fixedTime | fixedTime | 775 | const,const | 1 | NULL |
+----+-------------+--------------+-------+---------------+-----------+---------+-------------+------+-------+
1 row in set (9.27 sec)
Query OK, 0 rows affected (9.28 sec)