module
CQL::Performance::SQLUtils
Overview
SQL normalization and formatting
Defined in:
performance/utilities.crConstant Summary
-
NORMALIZABLE_TOKEN =
/\$\d+|\b\d+\b|'.+?'|\s+/ -
One pass over the original four rewrites (placeholders, bare numbers, quoted literals, whitespace runs). Each alternative starts with a distinct character class, so leftmost matching reproduces the sequential output exactly.
\$\d+must stay before\b\d+\bso the digits of a$1placeholder are not matched as a bare number. A literal?is already its own replacement and needs no alternative. -
NORMALIZED_CACHE_LIMIT =
512
Class Method Summary
- .format_params(params : Array(DB::Any), max_length : Int32 = 50) : String
-
.normalize_sql(sql : String) : String
Queries repeat the same SQL text (values are bound), so each text is normalized once; at most
NORMALIZED_CACHE_LIMITare kept, the oldest inserted dropped first. - .normalized_cache_size : Int32
- .truncate_sql(sql : String, max_length : Int32 = 100) : String
Class Method Detail
def self.normalize_sql(sql : String) : String
#
Queries repeat the same SQL text (values are bound), so each text is normalized once; at
most NORMALIZED_CACHE_LIMIT are kept, the oldest inserted dropped first.