v.21.9Improvement

Add log_formatted_queries Setting for Enhanced Query Analysis

Add setting log_formatted_queries to log additional formatted query into system.query_log. It's useful for normalized query analysis because functions like normalizeQuery and normalizeQueryKeepNames don't parse/format queries in order to achieve better performance. #27380 (Amos Bird).
Added the log_formatted_queries setting to log an additional formatted version of queries into system.query_log.

Why it matters

This feature provides a normalized and formatted representation of queries in system.query_log, improving the ability to analyze and understand query patterns. Unlike existing normalization functions such as normalizeQuery and normalizeQueryKeepNames, which avoid parsing and formatting for performance reasons, this setting enables capturing fully formatted queries for more detailed analysis.

How to use it

Enable the feature by setting log_formatted_queries to 1 (true) in your server configuration or session settings. Once enabled, additional formatted queries will be logged in the system.query_log table alongside the original query entries.