•Server features other than the Performance Schema use normalized statement digests that take up to max_digest_length  bytes. 

•The Performance Schema does not further truncate normalized statement digests that it stores, but allocates more memory than max_digest_length  bytes per digest, which is unnecessary. 

•If max_digest_length  equals performance_schema_max_digest_length : 

•Server features other than the Performance Schema use normalized statement digests that take up to max_digest_length  bytes. 

•The Performance Schema does not further truncate normalized statement digests that it stores, and allocates the same amount of memory as max_digest_length  bytes per digest. 

•If max_digest_length  is greater than performance_schema_max_digest_length : 

•Server features other than the Performance Schema use normalized statement digests that take up to max_digest_length  bytes. 

•The Performance Schema further truncates normalized statement digests that it stores, and allocates less memory than max_digest_length  bytes per digest. 

Because the Performance Schema statement event tables might store many digests, setting performance_schema_max_digest_length  smaller than max_digest_length  enables administrators to balance these factors: 

•The need to have long normalized statement digests available to server features outside the Performance Schema 

•Many concurrent sessions, each of which allocates digest-computation memory 

•The need to limit memory consumption by the Performance Schema statement event tables when storing many statement digests 

The performance_schema_max_digest_length  setting is not per session, it is per statement, and a session can store multiple statements in the events_statements_history  table. A typical number of statements in this table is 10 per session, so each session consumes 10 times the memory indicated by the performance_schema_max_digest_length  value, for this table alone. 

Also, there are many statements (and digests) collected globally, most notably in the events_statements_history_long  table. Here, too, N  statements stored consumes N  times the memory indicated by the performance_schema_max_digest_length  value. 

To assess the amount of memory used for SQL statement storage and digest computation, use the SHOW ENGINE PERFORMANCE_SCHEMA STATUS  statement, or monitor these instruments: 

mysql> SELECT NAME FROM performance_schema.setup_instruments WHERE NAME LIKE ’%.sqltext’; +------------------------------------------------------------------+ | NAME | +------------------------------------------------------------------+ | memory/performance_schema/events_statements_history.sqltext | | memory/performance_schema/events_statements_current.sqltext | | memory/performance_schema/events_statements_history_long.sqltext | +------------------------------------------------------------------+ mysql> SELECT NAME 

