MySQL :: MySQL 8.4 Reference Manual :: 29.12.20.3 Statement Summary Tables (original) (raw)

29.12.20.3 Statement Summary Tables

The Performance Schema maintains tables for collecting current and recent statement events, and aggregates that information in summary tables.Section 29.12.6, “Performance Schema Statement Event Tables” describes the events on which statement summaries are based. See that discussion for information about the content of statement events, the current and historical statement event tables, and how to control statement event collection, which is partially disabled by default.

Example statement event summary information:

mysql> SELECT *
       FROM performance_schema.events_statements_summary_global_by_event_name\G
*************************** 1. row ***************************
                 EVENT_NAME: statement/sql/select
                 COUNT_STAR: 54
             SUM_TIMER_WAIT: 38860400000
             MIN_TIMER_WAIT: 52400000
             AVG_TIMER_WAIT: 719600000
             MAX_TIMER_WAIT: 12631800000
              SUM_LOCK_TIME: 88000000
                 SUM_ERRORS: 0
               SUM_WARNINGS: 0
          SUM_ROWS_AFFECTED: 0
              SUM_ROWS_SENT: 60
          SUM_ROWS_EXAMINED: 120
SUM_CREATED_TMP_DISK_TABLES: 0
     SUM_CREATED_TMP_TABLES: 21
       SUM_SELECT_FULL_JOIN: 16
 SUM_SELECT_FULL_RANGE_JOIN: 0
           SUM_SELECT_RANGE: 0
     SUM_SELECT_RANGE_CHECK: 0
            SUM_SELECT_SCAN: 41
      SUM_SORT_MERGE_PASSES: 0
             SUM_SORT_RANGE: 0
              SUM_SORT_ROWS: 0
              SUM_SORT_SCAN: 0
          SUM_NO_INDEX_USED: 22
     SUM_NO_GOOD_INDEX_USED: 0
               SUM_CPU_TIME: 0
      MAX_CONTROLLED_MEMORY: 2028360
           MAX_TOTAL_MEMORY: 2853429
            COUNT_SECONDARY: 0
...

Each statement summary table has one or more grouping columns to indicate how the table aggregates events. Event names refer to names of event instruments in thesetup_instruments table:

Each statement summary table has these summary columns containing aggregated values (with exceptions as noted):

Theevents_statements_summary_by_digest table has these additional summary columns:

Theevents_statements_summary_by_digest table contains the following columns. These are neither grouping nor summary columns; they support statement sampling:

Theevents_statements_summary_by_program table has these additional summary columns:

The prepared_statements_instances table has these additional summary columns:

The statement summary tables have these indexes:

TRUNCATE TABLE is permitted for statement summary tables. It has these effects:

In addition, each statement summary table that is aggregated by account, host, user, or thread is implicitly truncated by truncation of the connection table on which it depends, or truncation ofevents_statements_summary_global_by_event_name. For details, seeSection 29.12.8, “Performance Schema Connection Tables”.

In addition, truncatingevents_statements_summary_by_digest implicitly truncatesevents_statements_histogram_by_digest, and truncatingevents_statements_summary_global_by_event_name implicitly truncatesevents_statements_histogram_global.

Statement Digest Aggregation Rules

If the statements_digest consumer is enabled, aggregation intoevents_statements_summary_by_digest occurs as follows when a statement completes. Aggregation is based on the DIGEST value computed for the statement.

The row with DIGEST =NULL is maintained because Performance Schema tables have a maximum size due to memory constraints. The DIGEST = NULL row permits digests that do not match other rows to be counted even if the summary table is full, using a common“other” bucket. This row helps you estimate whether the digest summary is representative:

Stored Program Instrumentation Behavior

For stored program types for which instrumentation is enabled in the setup_objects table,events_statements_summary_by_program maintains statistics for stored programs as follows:

See also Section 29.4.3, “Event Pre-Filtering”.