Documentation Home
MySQL 8.0 リファレンスマニュアル
Download this Manual
PDF (US Ltr) - 36.1Mb
PDF (A4) - 36.2Mb


このページは機械翻訳したものです。

28.4.4.22 ps_trace_statement_digest() プロシージャ

特定のステートメントダイジェストのすべてのパフォーマンススキーマインストゥルメンテーションをトレースします。

パフォーマンススキーマ events_statements_summary_by_digest テーブル内で目的のステートメントが見つかった場合は、その DIGEST カラムの MD5 値をこのプロシージャに指定し、ポーリング期間と間隔を指定します。 結果は、そのダイジェストについてパフォーマンススキーマ内で追跡されたすべての統計のレポートです。

また、この手順では、間隔中にダイジェストの最長実行例に対して EXPLAIN の実行も試行されます。 パフォーマンススキーマが長い SQL_TEXT 値を切り捨てるため、この試行は失敗する可能性があります。 その結果、解析エラーのため、EXPLAIN は失敗します。

このプロシージャは、sql_log_bin システム変数のセッション値を操作して、実行中にバイナリロギングを無効にします。 これは制限付き操作であるため、このプロシージャには制限付きセッション変数を設定するのに十分な権限が必要です。 セクション5.1.9.1「システム変数権限」を参照してください。

パラメータ
  • in_digest VARCHAR(32): 分析するステートメントダイジェスト識別子。

  • in_runtime INT: 分析を実行する時間 (秒)。

  • in_interval DECIMAL(2,2): スナップショットを取得しようとする秒単位の分析間隔 (小数も可)。

  • in_start_fresh BOOLEAN: 起動前にパフォーマンススキーマ events_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)