The BDBAFH Chronicles #002: The N+1 Query Cascade & The 15-Minute CPU Meltdown
Our senior backend engineer complained that PostgreSQL was “unscalable.” I opened pg_stat_statements and stared into the abyss: a single HTTP API request was firing 150,000 individual…
Incident #002 of the BDBAFH Chronicles: The N+1 Query Cascade & The 15-Minute CPU Meltdown. Dark-humor fiction: no real people, companies or incidents.

Our senior backend engineer complained that PostgreSQL was “unscalable.” I opened pg_stat_statements and stared into the abyss: a single HTTP API request was firing 150,000 individual SELECT * FROM items WHERE id = ? queries inside a nested application loop over a 500,000-row recordset, completely pinning all 16 CPU cores at 100% and triggering thermal throttling on the server rack.
— “Why didn’t you write a single JOIN?” I asked.
— “ORMs handle queries automatically,” he insisted. “Hand-writing SQL is an anti-pattern.”
I didn’t argue. I enabled a custom PostgreSQL extension on the development cluster. Every time his application session fired more than 100 queries for a single request, the database driver introduced an exponential latency penalty (1ms per subsequent query) and triggered his IDE to auto-format his code using wingdings font.
After waiting 40 minutes for his local unit tests to pass, he learned how to write JOIN clauses and eager-load relations.
The BDBAFH Chronicles are works of dark-humor fiction inspired by the Bastard Operator From Hell and The Daily WTF. Names, companies and incidents are invented, and any resemblance to real ones is coincidental. Commands and outputs are illustrative and untested: do not run them on a system you care about.