Reproduce a Slow Query with Realistic Data Volume Before You Touch It
A query that is slow on ten million rows will not be slow on the two hundred rows in your development database, and the planner will pick a different plan there too, so measuring locally tells you nothing. You reproduce by generating data at the right scale, with generate_series or pgbench in PostgreSQL, keeping the distribution realistic (a few customers with thousands of orders, most with three) and then running ANALYZE so the statistics match. Without a reproduction you cannot tell a fix from a coincidence, because the only other place to test is production.
Questions this Concept answers
Why does measuring a query against two hundred rows in a development database tell you nothing?
J
jeremy
Text
How to Generate Test Data in PostgreSQL with generate_series
This page shows how to fill a PostgreSQL table with large amounts of test data using generate_series and random values. It explains why a query that finishes instantly on a few hundred development ro…