Building a PostgreSQL load tester

Building a PostgreSQL load tester

My benchmarking strategy with pgreplay is pretty simple: first capture logs from your production cluster that contain all executed queries then feed this to pgreplay which will replay those queries against the new cluster. As prepared statements with query parameters come in two log lines, it’s possible for our parsing process to successfully parse a log line (like the entry) without it being complete, as it lacks parameters. As we parse our items, we track the last recognised log line against each on-goinging connection’s and pass this mapping to so that it can match subsequent entries against unbound executes:

By maintaining the unbound cache as part of a stateful parsing function we can support the two-staging process of combining execute and detail lines into a single replay item.

Source: blog.lawrencejones.dev