Rechercher dans le manuel MySQL

27.4.4.22 The ps_trace_statement_digest() Procedure

Traces all Performance Schema instrumentation for a specific statement digest.

If you find a statement of interest within the Performance Schema events_statements_summary_by_digest table, specify its DIGEST column MD5 value to this procedure and indicate the polling duration and interval. The result is a report of all statistics tracked within Performance Schema for that digest for the interval.

The procedure also attempts to execute EXPLAIN for the longest running example of the digest during the interval. This attempt might fail because the Performance Schema truncates long SQL_TEXT values. Consequently, EXPLAIN will fail due to parse errors.

This procedure disables binary logging during its execution by manipulating the session value of the sql_log_bin system variable. That is a restricted operation, so the procedure requires privileges sufficient to set restricted session variables. See Section 5.1.9.1, “System Variable Privileges”.

Parameters
  • in_digest VARCHAR(32): The statement digest identifier to analyze.

  • in_runtime INT: How long to run the analysis in seconds.

  • in_interval DECIMAL(2,2): The analysis interval in seconds (which can be fractional) at which to try to take snapshots.

  • in_start_fresh BOOLEAN: Whether to truncate the Performance Schema events_statements_history_long and events_stages_history_long tables before starting.

  • in_auto_enable BOOLEAN: Whether to automatically enable required consumers.

Contents Haut

Example
  1. mysql> CALL sys.ps_trace_statement_digest('891ec6860f98ba46d89dd20b0c03652c', 10, 0.1, TRUE, TRUE);
  2. +--------------------+
  3. | SUMMARY STATISTICS |
  4. +--------------------+
  5. | SUMMARY STATISTICS |
  6. +--------------------+
  7. 1 row in set (9.11 sec)
  8.  
  9. +------------+-----------+-----------+-----------+---------------+------------+------------+
  10. | executions | exec_time | lock_time | rows_sent | rows_examined | tmp_tables | full_scans |
  11. +------------+-----------+-----------+-----------+---------------+------------+------------+
  12. |         21 | 4.11 ms   | 2.00 ms   |         0 |            21 |          0 |          0 |
  13. +------------+-----------+-----------+-----------+---------------+------------+------------+
  14. 1 row in set (9.11 sec)
  15.  
  16. +------------------------------------------+-------+-----------+
  17. | event_name                               | count | latency   |
  18. +------------------------------------------+-------+-----------+
  19. | stage/sql/statistics                     |    16 | 546.92 us |
  20. | stage/sql/freeing items                  |    18 | 520.11 us |
  21. | stage/sql/init                           |    51 | 466.80 us |
  22. ...
  23. | stage/sql/cleaning up                    |    18 | 11.92 us  |
  24. | stage/sql/executing                      |    16 | 6.95 us   |
  25. +------------------------------------------+-------+-----------+
  26. 17 rows in set (9.12 sec)
  27.  
  28. +---------------------------+
  29. | LONGEST RUNNING STATEMENT |
  30. +---------------------------+
  31. | LONGEST RUNNING STATEMENT |
  32. +---------------------------+
  33. 1 row in set (9.16 sec)
  34.  
  35. +-----------+-----------+-----------+-----------+---------------+------------+-----------+
  36. | thread_id | exec_time | lock_time | rows_sent | rows_examined | tmp_tables | full_scan |
  37. +-----------+-----------+-----------+-----------+---------------+------------+-----------+
  38. |    166646 | 618.43 us | 1.00 ms   |         0 |             1 |          0 |         0 |
  39. +-----------+-----------+-----------+-----------+---------------+------------+-----------+
  40. 1 row in set (9.16 sec)
  41.  
  42. # Truncated for clarity...
  43. +-----------------------------------------------------------------+
  44. | sql_text                                                        |
  45. +-----------------------------------------------------------------+
  46. | select hibeventhe0_.id as id1382_, hibeventhe0_.createdTime ... |
  47. +-----------------------------------------------------------------+
  48. 1 row in set (9.17 sec)
  49.  
  50. +------------------------------------------+-----------+
  51. | event_name                               | latency   |
  52. +------------------------------------------+-----------+
  53. | stage/sql/init                           | 8.61 us   |
  54. | stage/sql/init                           | 331.07 ns |
  55. ...
  56. | stage/sql/freeing items                  | 30.46 us  |
  57. | stage/sql/cleaning up                    | 662.13 ns |
  58. +------------------------------------------+-----------+
  59. 18 rows in set (9.23 sec)
  60.  
  61. +----+-------------+--------------+-------+---------------+-----------+---------+-------------+------+-------+
  62. | id | select_type | table        | type  | possible_keys | key       | key_len | ref         | rows | Extra |
  63. +----+-------------+--------------+-------+---------------+-----------+---------+-------------+------+-------+
  64. |  1 | SIMPLE      | hibeventhe0_ | const | fixedTime     | fixedTime | 775     | const,const |    1 | NULL  |
  65. +----+-------------+--------------+-------+---------------+-----------+---------+-------------+------+-------+
  66. 1 row in set (9.27 sec)
  67.  
  68. Query OK, 0 rows affected (9.28 sec)

Find a PHP function

Document created the 26/06/2006, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/mysql-rf-sys-ps-trace-statement-digest.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.

References

  1. View the html document Language of the document:en Manuel MySQL : https://dev.mysql.com/

These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.

Contents Haut