zenit
zenit copied to clipboard
Standardized fingerprint of a query
Reported by: Joffrey MICHAIE <@db_cat_twitter>
Related issues: #42
The tools pt-query-digest, percona / go-mysql and proxysql calculate different fingerprint for the same query, maybe is possible to use a standard. The idea of this issue is open thread to discuss about it.
- pt-fingerprint
- percona/go-mysql: Use regular expression.
- percona-toolkit: Use regular expression.
- ProxySQL: No use regular expression.
Percona rules:
- Shorten multi-value INSERT statements to a single VALUES() list.
- Strip comments.
- Replace all literals, such as quoted strings. For efficiency, the code that replaces literal numbers is somewhat non-selective, and might replace some things as numbers when they really are not. Hexadecimal literals are also replaced. NULL is treated as a literal. Numbers embedded in identifiers are also replaced, so tables named similarly will be fingerprinted to the same values (e.g. users_2009 and users_2010 will fingerprint identically).
- Collapse all whitespace into a single space.
- Lowercase the entire query.
- Replace all literals inside of IN() and VALUES() lists with a single placeholder, regardless of cardinality.