PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_SUMMARY_BY_DIGEST table is used to aggregate and display SQL statement execution statistics by statement digest (DIGEST), enabling users to analyze the execution frequency, latency distribution, resource consumption, and distributed execution characteristics of various SQL statements in TDSQL Boundless clusters.events_statements_summary_by_digest table aggregates all SQL statements by the unique key (SCHEMA_NAME, DIGEST). Each row represents the cumulative execution statistics for a specific SQL template, which is a statement fingerprint formed after parameter normalization. The main features of this table are as follows:SUM_DISTRIBUTED field is provided to count the number of times such SQL statements are executed in a distributed manner (where a single SQL statement accesses multiple Replication Groups), thereby demonstrating the distributed execution feature of TDSQL Boundless.QUERY_SAMPLE_TEXT), along with its collection timestamp and latency, to facilitate viewing the actual text of representative SQL statements.performance_schema system variable to ON. You can clear the statistical data by executing TRUNCATE TABLE performance_schema.events_statements_summary_by_digest.Field Name | Type | Description |
SCHEMA_NAME | varchar(64) | Name of the database to which the statement belongs. If the statement does not specify a database name, the value is NULL. |
DIGEST | varchar(64) | Hash value of the SQL statement digest, which is the unique identifier for the same statement template. |
DIGEST_TEXT | longtext | Normalized SQL statement template text, where constant values are replaced with ?. |
COUNT_STAR | bigint unsigned | Total number of executions for the SQL template. |
SUM_TIMER_WAIT | bigint unsigned | Total execution time for the SQL template, measured in picoseconds (ps). |
MIN_TIMER_WAIT | bigint unsigned | Minimum single-execution time for the SQL template, measured in picoseconds. |
AVG_TIMER_WAIT | bigint unsigned | Average single-execution time for the SQL template, measured in picoseconds. |
MAX_TIMER_WAIT | bigint unsigned | Maximum single-execution time for the SQL template, measured in picoseconds. |
SUM_LOCK_TIME | bigint unsigned | Total lock wait time for the SQL template, measured in picoseconds. |
SUM_ERRORS | bigint unsigned | Total number of failed executions for the SQL template. |
SUM_WARNINGS | bigint unsigned | Total number of alarms generated by the SQL template. |
SUM_ROWS_AFFECTED | bigint unsigned | Total number of rows affected by the SQL template (INSERT, UPDATE, DELETE, and so on). |
SUM_ROWS_SENT | bigint unsigned | Total number of rows returned to the client by the SQL template. |
SUM_ROWS_EXAMINED | bigint unsigned | Total number of rows scanned by the SQL template. |
SUM_CREATED_TMP_DISK_TABLES | bigint unsigned | Total number of on-disk temporary tables created by the SQL template. |
SUM_CREATED_TMP_TABLES | bigint unsigned | Total number of temporary tables (including in-memory temporary tables) created by the SQL template. |
SUM_SELECT_FULL_JOIN | bigint unsigned | Total number of full table joins triggered due to no index being used by the SQL template. |
SUM_SELECT_FULL_RANGE_JOIN | bigint unsigned | Total number of full range joins (range search) triggered by the SQL template. |
SUM_SELECT_RANGE | bigint unsigned | Total number of times range scans were used on the first table by the SQL template. |
SUM_SELECT_RANGE_CHECK | bigint unsigned | Total number of row-by-row range checks triggered by the SQL template, which usually indicates poor index selection for JOIN operations. |
SUM_SELECT_SCAN | bigint unsigned | Total number of full table scans performed on the first table by the SQL template. |
SUM_SORT_MERGE_PASSES | bigint unsigned | Total number of merge passes for sorting operations performed by the SQL template. |
SUM_SORT_RANGE | bigint unsigned | Total number of sorting operations performed based on range scans by the SQL template. |
SUM_SORT_ROWS | bigint unsigned | Total number of rows involved in sorting operations by the SQL template. |
SUM_SORT_SCAN | bigint unsigned | Total number of sorting operations performed based on full table scans by the SQL template. |
SUM_NO_INDEX_USED | bigint unsigned | Total number of executions where no index was used by the SQL template. |
SUM_NO_GOOD_INDEX_USED | bigint unsigned | Total number of executions where no index was used because the optimizer deemed no suitable index was available, for the SQL template. |
SUM_DISTRIBUTED | bigint unsigned | Total number of executions performed in distributed mode for the SQL template. An execution is counted as 1 if it involves modifying more than one Replication Group; otherwise, it is counted as 0. This field is a self-developed field of TDSQL Boundless. |
FIRST_SEEN | timestamp(6) | Timestamp when the SQL template was first recorded. |
LAST_SEEN | timestamp(6) | Timestamp when the SQL template was last recorded. |
QUANTILE_95 | bigint unsigned | P95 quantile of execution time for the SQL template, measured in picoseconds. |
QUANTILE_99 | bigint unsigned | P99 quantile of execution time for the SQL template, measured in picoseconds. |
QUANTILE_999 | bigint unsigned | P999 quantile of execution time for the SQL template, measured in picoseconds. |
QUERY_SAMPLE_TEXT | longtext | Representative raw SQL statement text for the template (with parameter values preserved), which can be used to reproduce the execution. |
QUERY_SAMPLE_SEEN | timestamp(6) | Timestamp when QUERY_SAMPLE_TEXT was collected. |
QUERY_SAMPLE_TIMER_WAIT | bigint unsigned | Execution time of the specific run when QUERY_SAMPLE_TEXT was collected, measured in picoseconds. |
*_TIMER_WAIT, SUM_LOCK_TIME, QUANTILE_*, QUERY_SAMPLE_TIMER_WAIT) are measured in picoseconds, where 1 second equals 1,000,000,000,000 picoseconds.SELECT SCHEMA_NAME, DIGEST_TEXT, COUNT_STAR,SUM_TIMER_WAIT / 1000000000 AS SUM_TIMER_MS,AVG_TIMER_WAIT / 1000000000 AS AVG_TIMER_MSFROM performance_schema.events_statements_summary_by_digestORDER BY COUNT_STAR DESCLIMIT 10;
SELECT SCHEMA_NAME, DIGEST_TEXT, COUNT_STAR,QUANTILE_95 / 1000000000 AS P95_MS,QUANTILE_99 / 1000000000 AS P99_MS,QUANTILE_999 / 1000000000 AS P999_MSFROM performance_schema.events_statements_summary_by_digestWHERE QUANTILE_99 > 100000000000ORDER BY QUANTILE_99 DESC;
SELECT SCHEMA_NAME, DIGEST_TEXT, COUNT_STAR,SUM_NO_INDEX_USED, SUM_SELECT_SCAN, SUM_ROWS_EXAMINEDFROM performance_schema.events_statements_summary_by_digestWHERE SUM_NO_INDEX_USED > 0 OR SUM_SELECT_SCAN > 0ORDER BY SUM_ROWS_EXAMINED DESC;
SUM_DISTRIBUTED field counts the number of times SQL statements are executed in a distributed manner (involving more than one participating node). The following section demonstrates its behavior through a specific scenario:CREATE DATABASE db;CREATE TABLE db.t1 (a INT PRIMARY KEY, b VARCHAR(30));CREATE TABLE db.t2 (a INT PRIMARY KEY, b VARCHAR(30));-- Distribute t1 and t2 to different replication groups.USE performance_schema;TRUNCATE TABLE events_statements_summary_by_digest;USE db;INSERT INTO t1 VALUES (111, 222);INSERT INTO t2 VALUES (111, 222);UPDATE t1, t2 SET t1.b = 333, t2.b = 333 WHERE t1.a = 111 AND t2.a = 111;SELECT DIGEST_TEXT, COUNT_STAR, SUM_DISTRIBUTEDFROM performance_schema.events_statements_summary_by_digestWHERE SCHEMA_NAME = 'db';
DIGEST_TEXT COUNT_STAR SUM_DISTRIBUTEDINSERT INTO `t1` VALUES (...) 1 0INSERT INTO `t2` VALUES (...) 1 0UPDATE `t1` , `t2` SET `t1` . `b` = ? , `t2` . `b` = ? WHERE `t1` . `a` = ? AND `t2` . `a` = ? 1 1
SUM_DISTRIBUTED field is 0 because both INSERT statements access only a single table and each statement involves only one participating node.SUM_DISTRIBUTED field is 1 because the UPDATE statement simultaneously updates t1 and t4, which reside in different replication groups, involving more than one participating node.SELECT DIGEST, DIGEST_TEXT, QUERY_SAMPLE_TEXT,QUERY_SAMPLE_SEEN,QUERY_SAMPLE_TIMER_WAIT / 1000000000 AS SAMPLE_TIMER_MSFROM performance_schema.events_statements_summary_by_digestWHERE DIGEST = '<specified DIGEST value>'\\G
TRUNCATE TABLE performance_schema.events_statements_summary_by_digest;
フィードバック