On this page

What This Blog Will Cover

What Is a Database Index

Why Reads Get Faster

Why Every Write Pays

The Other Costs: Storage and Memory

The Core Trade-off: Reads Versus Writes

Where This Matters Most

The Rules for Indexing Well

Index the Queries You Actually Run

Avoid Indexing Frequently Changing Columns

Avoid Indexing Low-Cardinality Fields

Measure Before Adding More

A Few Refinements Worth Knowing

The Answer That Wins Interviews

Key Takeaways

Database Indexes Are Not Free: The Read, Write, and Storage Trade-offs You Need to Know

Image
Arslan Ahmad
The Hidden Cost of Database Indexes, Explained From How They Work to How to Decide When One Is Worth Adding
Image

What This Blog Will Cover

What Is a Database Index

Why Reads Get Faster

Why Every Write Pays

The Other Costs: Storage and Memory

The Core Trade-off: Reads Versus Writes

Where This Matters Most

The Rules for Indexing Well

Index the Queries You Actually Run

Avoid Indexing Frequently Changing Columns

Avoid Indexing Low-Cardinality Fields

Measure Before Adding More

A Few Refinements Worth Knowing

The Answer That Wins Interviews

Key Takeaways

What This Blog Will Cover

  • What an index actually is
  • Why reads get faster
  • Why every write pays
  • Where over-indexing hurts most
  • How to answer this in interviews

There is a moment in almost every system design discussion when reads become slow, and the reflexive answer appears.

Someone says they will add an index. It is the most common reaction to a performance problem, and it is not wrong, but it is incomplete.

The problem with the reflexive answer is that it treats an index as a free improvement, a switch you flip to make queries faster with no downside. That is not how indexes work. Every index has a cost, and a candidate or engineer who reaches for one without acknowledging that cost reveals a shallow understanding of how databases actually behave.

Database indexes are not free.

An index speeds up reads, but it slows down writes, consumes storage, and adds maintenance overhead.

One index is usually fine. Ten indexes on a write-heavy table can quietly cripple its performance.

The difference between a weak answer and a strong one is not whether you reach for an index, but whether you understand and explain what it costs.

This article explains the full picture of database indexing, from how an index works to why it speeds up reads, why it slows down writes, what it costs in storage and memory, and how to decide when one is worth adding. It ends with the kind of answer that demonstrates real understanding in a system design interview.

The goal is to replace the reflexive "add an index" with genuine reasoning about the trade-off.

What Is a Database Index

To understand why indexes are not free, you first need to understand what an index is.

An index is a separate data structure that the database maintains alongside a table to make finding rows faster.

Without an index, when the database needs to find rows matching a condition, it has no choice but to perform a full table scan, examining every single row to check whether it matches. For a table with a hundred rows, this is instant. For a table with a hundred million rows, it is painfully slow, because the database must read and check all hundred million.

An index solves this by keeping a sorted, searchable structure of the indexed values along with pointers to the rows that contain them.

The most common type is a B-tree index, a balanced tree structure that keeps values in sorted order and allows the database to find a value through a small number of steps rather than scanning everything.

The speed difference is dramatic. Searching a sorted tree takes a number of steps proportional to the logarithm of the table size, rather than proportional to the size itself. For a table of a hundred million rows, a full scan examines a hundred million rows, while a B-tree lookup reaches the target in roughly twenty-seven steps. This is the enormous read benefit that makes indexes so tempting.

The key point to hold onto is that the index is a separate structure. It is not part of the table itself but an additional copy of certain data, kept in sorted order, that the database must maintain. That word, maintain, is where the cost lives.

Why Reads Get Faster

The read benefit of an index is real and significant, and it is worth understanding precisely what it accelerates.

The most obvious benefit is fast lookups by an exact value. If you index a user's email address, finding the user with a specific email becomes a quick tree traversal instead of a scan of the entire users table. This is the canonical use of an index.

Because a B-tree keeps values in sorted order, an index also accelerates range queries.

Table scan vs. index lookup
Table scan vs. index lookup

Finding all orders placed between two dates, or all values greater than some threshold, can use the index to jump to the start of the range and read forward, rather than scanning the whole table. The sorted structure makes ranges efficient.

Indexes also speed up sorting and joins.

A query that orders results by an indexed column can read them in order directly from the index, avoiding a separate sort step.

A join between two tables can use an index on the join column to find matching rows quickly rather than scanning.

In some cases, an index can satisfy a query entirely on its own.

If an index contains all the columns a query needs, the database can answer the query from the index without ever touching the table. This is called a covering index or an index-only scan, and it is one of the most powerful read optimizations available.

All of this explains why the instinct to add an index is so strong.

The read benefits are large and immediately visible. The trouble is that this benefit is only half the story, and the other half is invisible until it hurts.

Why Every Write Pays

Here is the cost that the reflexive answer ignores. Every index speeds up reads, but every index slows down writes.

To understand why, return to the fact that an index is a separate structure the database must keep in sync with the table.

When you insert a new row, the database does not only add it to the table. It must also add a corresponding entry to every index on that table, placing the new value in the correct sorted position in each one.

A table with five indexes means that every single insert now updates six structures, the table and all five indexes.

The same is true for updates.

When you update a column that is indexed, the database must update the index too, which typically means removing the old value from its position and inserting the new value in its correct place.

If a write touches several indexed columns, several indexes must be updated.

Deletes carry the same burden. Removing a row requires removing its entry from every index, not just from the table.

This is write amplification.

A single logical write becomes many physical writes, one to the table and one to each index. The maintenance is not trivial either, because keeping a B-tree balanced and sorted involves work like splitting and reorganizing pages as data is added.

The more indexes a table has, the more this work multiplies.

This is why one index is usually fine, but ten indexes start to bleed.

Every index costs writes
Every index costs writes

A single extra structure to maintain on each write is a modest cost.

Ten extra structures to maintain on every insert, update, and delete is a heavy tax on write performance, and on a high-volume write path it can become the dominant bottleneck.

The reads got faster, but the writes are now paying for it on every operation.

The Other Costs: Storage and Memory

Beyond the write penalty, indexes carry two more costs that are easy to overlook.

The first is storage. An index is a copy of indexed data plus the structure that organizes it, and that copy takes disk space.

A single index may be small relative to the table, but a heavily indexed table can end up with indexes that collectively rival or exceed the size of the data itself. Storage is cheap, but it is not free, and on a large table the difference is meaningful.

The second is memory.

Databases keep frequently used data and indexes in memory to serve queries quickly. Indexes compete for this limited memory along with the actual table data.

Every index that the database tries to keep cached takes space that could have held something else.

An excess of rarely used indexes can push more useful data out of memory, which ironically can hurt overall performance.

These costs reinforce the central point.

An index is not a pure gain. It trades read speed for slower writes, more storage, and more memory pressure.

A good engineer weighs all of these rather than seeing only the read benefit.

The Core Trade-off: Reads Versus Writes

The whole question of indexing comes down to a single trade-off.

An index improves read performance at the cost of write performance and storage.

Whether that trade is worth making depends entirely on the workload.

For a read-heavy workload, where data is written once and read many times, indexes are usually a clear win. The slowdown on the rare writes is far outweighed by the speedup on the frequent reads. A table that is queried constantly but updated rarely is an excellent candidate for indexing.

For a write-heavy workload, where data is written constantly, indexes are far more dangerous. Each index taxes every write, and on a high-volume ingest path that tax adds up fast.

A table receiving a flood of inserts can have its throughput cut significantly by carrying too many indexes. Here, every index must justify itself, because the cost is paid continuously.

This is why the read-to-write ratio of a table is the first thing to consider before adding an index.

The same index that is obviously worth it on a read-heavy table can be a serious mistake on a write-heavy one.

The trade-off is not abstract.

It plays out differently for every table depending on how it is used.

It is worth noting that this very trade-off is part of why some systems choose write-optimized storage engines.

Read vs. Write Tradeoffs
Read vs. Write Tradeoffs

Databases built for extreme write volumes often use storage structures designed to absorb writes efficiently rather than the B-tree indexes that relational databases rely on, precisely because the index maintenance cost on writes is so significant at scale.

Learn more about Read-heavy vs. Write-heavy workloads.

Where This Matters Most

The indexing trade-off is not equally important everywhere. It becomes critical in systems with high write volume or where write latency matters, and several common system types fall into this category.

Order history is a system where this trade-off appears constantly. Orders are written once and then read many times for display and reporting, which makes it read-heavy and a good candidate for indexing the access patterns. But the indexes must still match the actual queries, or they add write cost for no read benefit.

Payment transactions raise the stakes. This data is critical and often write-intensive, and write latency matters because users wait on payment confirmation. Here, indexes must be chosen with care, because every unnecessary index adds latency to a path where latency is felt directly.

Chat messages are a high write-volume system. Messages arrive in enormous numbers, and the write path is hot. Carrying many indexes on a messages table directly slows down the rate at which messages can be stored, so indexing must be minimal and deliberate.

User activity logs and analytics events are perhaps the clearest cases. These are append-heavy systems that ingest a constant, massive stream of writes. Every index on the ingestion path slows down how fast events can be recorded. Over-indexing these tables can throttle the entire ingest pipeline, which is why such systems often index sparingly and rely on separate systems optimized for querying the data later.

The pattern across all of these is that the more a system writes, the more carefully it must index. The reflexive addition of indexes that might be harmless on a small read-heavy table can be genuinely damaging on these high-volume write paths.

The Rules for Indexing Well

Given the trade-off, a set of practical rules guides good indexing. Following them keeps the read benefits while avoiding the worst of the write costs.

Index the Queries You Actually Run

The first rule is to index based on real access patterns, not speculation.

An index is only valuable if queries actually use it, and an index that no query uses provides no read benefit while still taxing every write. Before adding an index, identify the specific queries it will accelerate. If you cannot name the query, you should not add the index.

Avoid Indexing Frequently Changing Columns

The second rule is to be cautious about indexing columns that change often. Recall that updating an indexed column requires updating the index, removing the old value and inserting the new one.

A column that is updated constantly therefore makes its index expensive to maintain. Indexing a stable column like a creation timestamp is cheap to keep current, while indexing a rapidly changing column means paying the index maintenance cost on a huge fraction of writes.

Avoid Indexing Low-Cardinality Fields

The third rule concerns cardinality, which is the number of distinct values in a column.

A high-cardinality column like a user identifier or an email address has many distinct values, so an index on it is highly selective, meaning a lookup narrows down to very few rows. This is exactly what indexes are good at.

A low-cardinality column is the opposite.

Consider a status field whose value is one of active or inactive. Indexing this is usually a poor idea, because a query for active rows might match a large fraction of the entire table, and at that point an index provides little benefit over a scan.

The database's query planner often recognizes this and ignores such an index entirely, which means it adds write cost while providing no read benefit.

When you do need to query a low-cardinality field, a more targeted solution like a partial index, which indexes only the rows matching a specific condition, is often far more efficient than a full index on the column.

Measure Before Adding More

The fourth rule is to measure rather than guess. Before adding several more indexes, examine how queries actually execute, using the database's tools to see whether a query is using an index or scanning. Add indexes deliberately, one at a time, in response to a real performance need, and verify that each one is used and helps. Periodically review existing indexes and remove ones that are unused or duplicated, because they are pure cost. Indexing is an ongoing decision informed by measurement, not a one-time act of adding everything that might help.

A Few Refinements Worth Knowing

Beyond the core rules, a few refinements separate competent indexing from expert indexing.

A composite index on multiple columns can serve queries that filter on those columns together, but the order of columns matters, since such an index helps queries that use its leftmost columns and not ones that use only the later columns.

A covering index that includes all the columns a query needs can answer the query without touching the table at all, which is a powerful optimization for hot queries. And a partial index that covers only a subset of rows keeps the index small and cheap while still accelerating the queries that matter. Knowing these tools lets you get the read benefit while minimizing the write and storage cost.

The Answer That Wins Interviews

All of this leads to the practical payoff, which is how to handle indexing in a system design interview.

The reflexive answer marks a candidate as junior, while the considered answer signals real understanding.

The weak answer is simply, "We'll add an index." It is not wrong, but it treats the index as free and reveals no awareness of the cost. Interviewers hear this constantly, and it does nothing to distinguish a candidate.

The strong answer names the trade-off explicitly. It sounds like, "I'll add an index to support this access pattern, but I'll be deliberate about it, because each index improves reads at the cost of write latency and storage. Since this is a write-heavy table, I'll keep the indexes minimal and only index the queries we actually run." This answer shows that you understand both sides of the decision and that you are weighing them against the specific workload.

This is exactly the kind of reasoning interviewers want to hear, because it demonstrates trade-off thinking, which is the single clearest signal of senior-level judgment in a system design interview.

The candidate who explains why and at what cost stands out from the many who simply reach for the index.

The same principle applies in real engineering, where the difference between a healthy database and a struggling one is often the discipline to index deliberately rather than reflexively.

Key Takeaways

  • Indexes are not free, because they speed up reads but slow down writes, consume storage, and compete for memory.

  • An index is a separate sorted structure, usually a B-tree, that the database must keep in sync with the table on every write.

  • Every write pays for every index, since each insert, update, and delete must maintain the table and all of its indexes, which is why ten indexes can cripple write performance.

  • The core trade-off is reads versus writes, so the read-to-write ratio of a table should be the first thing you consider before indexing.

  • The trade-off matters most in write-heavy systems like chat messages, activity logs, and analytics events, where over-indexing throttles ingestion.

  • Good indexing follows clear rules, namely indexing real query patterns, avoiding frequently changing and low-cardinality columns, and measuring before adding more.

  • The interview-winning answer names the trade-off, explaining that you will index the access pattern carefully because each index trades write latency and storage for read speed.

An index is one of the most useful tools a database offers, but it is not a free one.

It buys read speed with write latency, storage, and memory, and the value of that trade depends entirely on the workload.

The engineers who use indexes well are the ones who understand both sides of the bargain, index deliberately in response to real query patterns, and stay mindful of the cost on every write. In an interview and in production alike, the goal is never just to add an index.

It is to index the access pattern with full awareness of what it costs, which is exactly the kind of trade-off thinking that separates strong engineers from the rest.

Databases

What our users say

AHMET HANIF

Whoever put this together, you folks are life savers. Thank you :)

Roger Cruz

The world gets better inch by inch when you help someone else. If you haven't tried Grokking The Coding Interview, check it out, it's a great resource!

ABHISHEK GUPTA

My offer from the top tech company would not have been possible without Grokking System Design. Many thanks!!

More From Designgurus
Annual Subscription
Get instant access to all current and upcoming courses for one year.

Access to 50+ courses

New content added monthly

Certificate of completion

$31.08

/month

Billed Annually

Recommended Course
Grokking the System Design Interview

Grokking the System Design Interview

178,110+ students

4.7

The #1 system design course for FAANG interviews, built by ex-FAANG hiring managers.

View Course
Join our Newsletter

Get the latest system design articles and interview tips delivered to your inbox.

Read More

From UUID to Snowflake: Understanding Database Fragmentation

Arslan Ahmad

Arslan Ahmad

PostgreSQL vs. MongoDB vs. DynamoDB

Arslan Ahmad

Arslan Ahmad

Grokking the Fundamentals of Database Replication for System Design Interviews

Arslan Ahmad

Arslan Ahmad

Scaling SQL Databases: 8 Challenges of Horizontally Scaling SQL Databases

Arslan Ahmad

Arslan Ahmad

Design Gurus logo
One-Stop Portal For Tech Interviews.
Copyright © 2026 Design Gurus, LLC. All rights reserved.