Normalized query fingerprints

To a person, it would be obvious that the following two queries are fundamentally the same:

UPDATE pgbench_accounts SET abalance = abalance + 1631 WHERE aid = 5829858; 
UPDATE pgbench_accounts SET abalance = abalance + 4172 WHERE aid = 567923; 

This isn't necessarily obvious to a log file parsing program though. Good database programming practice will often convert these to executing with prepared statements, which offers both a security improvement (resistance to SQL injection) as well as a potential performance gain. The pgbench program used to generate many of the examples in this book can be converted to them internally for executing statements:

$ pgbench -c4 -t 60 -M prepared pgbench 

Using prepared statements ...

Get PostgreSQL 10 High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.