zenit icon indicating copy to clipboard operation
zenit copied to clipboard

Standardized fingerprint of a query

Open debeando opened this issue 5 years ago • 0 comments

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.

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.

debeando avatar Aug 29 '18 19:08 debeando