59 minutes ago · 13 min read2690 words · Tech · hide

This one started with RegreSQL. Since The tests passed. The plan didn't. I've been loading production statistics into empty databases to see how much the plans alone can tell about a real workload. One paginated endpoint in a multi-tenant app wouldn't line up. Its plan was cheap, a cost of a few hundred and an estimate of one row, while pg_stat_statements in production had the same query reading thousands of buffers per call to return about eight rows. RegreSQL compares plans by cost, and so do I. The first thing my eyes go to in a plan is the cost on the top line: small number, cheap query, move on. This query's cost couldn't see its own problem, so before deciding what RegreSQL should do about it I rebuilt the case on a synthetic schema where every row can be accounted for. Two ordinary things cause it, one tenant much bigger than the others and a query sent as a prepared statement, and between them PostgreSQL ends up planning the big tenant's query from the small tenants' runs and…

Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town