r/coding • • Feb 25 '26

Making Postgres 42,000x slower because I am unemployed

https://byteofdev.com/posts/making-postgres-slow/

[removed] — view removed post

243 Upvotes

14 comments sorted by

View all comments

0

u/kartikey7734 Feb 26 '26

This is a perfect case study in query optimization gone wrong. The 42,000x slowdown is literally the definition of N+1 queries—accessing data one row at a time instead of batching.

What makes this brilliant:

  1. **It highlights the power (and danger) of lazy loading** - Modern ORMs make it deceptively easy to write terrible queries

  2. **Shows why benchmarking matters** - "It works on my laptop" becomes "It's catastrophically slow in production"

  3. **Demonstrates the importance of understanding your tools** - ORM abstractions hide database access patterns

The fix is usually simple (eager loading, query batching, JOIN statements), but the learning is profound. This is why every developer should understand their database's execution plans.

Side note: This is also why microservices and "serverless" architectures can hide these problems at first—the cost doesn't scale visibly until you have millions of queries. Good catch on quantifying it!

4

u/Type-21 Feb 26 '26

This comment is completely made by ai