sql-redactor
Normalize and redact SQL queries. Supports many dialects such as mysql, postgres, clickhouse, or hive.
This is useful for adding the observability to your database.
It is hard to find the higest QPS query when the queries are parameterized:
SELECT * FROM users where user_id = 1000with QPS 5SELECT * FROM users where user_id = 1001with QPS 3SELECT * FROM users where user_id = 1002with QPS 8- ..
SELECT * FROM articles where article_id = 2000with QPS 2SELECT * FROM articles where article_id = 2001with QPS 50SELECT * FROM articles where article_id = 2002with QPS 3
The parameters can be obscured to provide a better insight:
SELECT * FROM users where user_id = ?with QPS 3,000SELECT * FROM articles where article_id = ?with QPS 2,000
Usage
use redact;
use MySqlDialect;
let sql = "SELECT * FROM users
WHERE age > 18
AND city = 'New York'
ORDER BY last_name ASC;";
let redacted = "SELECT * FROM users WHERE age > ? AND city = ? ORDER BY last_name ASC;";
assert_eq!;
Bench
The redaction is fast compared to typical db latencies.
AMD Ryzen 9 3900X
30us
SELECT * FROM foo WHERE bar = 1
60~70 us
SELECT * FROM users
WHERE age > 18
AND city = 'New York'
ORDER BY last_name ASC;