Overview
SQL Digest is a fingerprint generated by historical SQL statements with parameters removed. It helps cluster SQL statements with the same structure but different parameters. Common use cases of SQL Digest include:- Finding other SQL statements with the same structure but different parameters in query history
- Tracking execution frequency, cumulative time, and other statistics of SQL with the same structure
- Identifying the most time-consuming SQL patterns in the system
Usage
Prerequisites
To enable this feature, you must set the FE configuration itemenable_sql_digest to true.
Execute the following statement to enable it dynamically:
enable_sql_digest = true to the FE configuration file fe.conf and restart FE.
After enabling this feature, you can install the AuditLoader plugin to perform statistical analysis on SQL statements.
Find similar SQL
Track daily execution count and time of similar SQL
Calculate average execution time of similar SQL
Aggregate similar SQL to analyze the most time-consuming pattern
Parameter normalization rules
- Constant values in SQL will be normalized. For example, similar SQL statements with
WHERE a = 1andWHERE a = 2will have the same Digest. - IN predicates will be normalized. For example, similar SQL statements with
IN (1,2,3)andIN (1,2)will have the same Digest. LIMIT Nclauses will be normalized. For example, similar SQL statements withLIMIT 10andLIMIT 30will have the same Digest.