Skip to content

The Fastest Database Query Is the One You Never Execute

Caching explained from first principles — what to cache, where to put it, and why the cheapest query is the one your database never sees.

By 1 min read
  • System Design Fundamentals
  • Caching
  • Redis
  • Backend
  • Performance
  • System Design
  • Software Architecture

A common assumption in software is: If something is slow, make the database faster.

But that's often the wrong solution. At scale, the biggest performance gains don't come from optimizing queries. They come from avoiding them.

Let's say 100,000 users are viewing the same product page. Without caching, your application might execute the same database query 100,000 times.

  • The database works harder.
  • Response times increase.
  • Infrastructure costs go up.

The Fastest Database Query Is the One You Never Execute

Now imagine storing that result in memory and reusing it for subsequent requests.

Instead of 100,000 database queries, you might only execute one. That's the power of caching.

One lesson that took me a while to appreciate: Performance isn't just about doing things faster. It's about doing fewer things.

That's why almost every large-scale system relies heavily on caching. Not because databases are slow. But because unnecessary work doesn't scale.

Before optimizing your database, ask yourself:Does this request need to reach the database at all? The answer can completely change your architecture.

Question: What's the biggest performance improvement you've seen from caching?

Keep reading