Scrivio Interview library
DesignPrincipal6 min read · updated 12 November 2026

Teams keep adding wide covering indexes to make specific API endpoints fast, and a 2 TB orders table now has 1.6 TB of indexes. At company scale, when should read performance be solved by indexes, and when by a different data shape such as read models, caches or an analytics store?

Indexes are the right tool for selective lookups on a few well-known query shapes in the transactional database. When endpoints need many columns, aggregates over large ranges, or the same hot result again and again, a wide index is an expensive copy of the table, and a read model, a cache or an analytics store is the better shape. We decide per endpoint with clear criteria (frequency, latency target, freshness, write rate) and review the cost regularly.

Why this question is asked

A 2 TB table with 1.6 TB of indexes is not a technical accident; it is the result of many reasonable local decisions. Each team made its endpoint fast by adding the index that covered its query, and nobody owned the total. Interviewers ask this at senior level because the answer is about economics and architecture, not syntax: what each index costs the whole system, and when the problem should be solved with a different shape of data. In this answer, we will recap what a covering index trades, count the real cost of wide indexes, look at the alternatives and what each suits, and set criteria and a review process.

1A Quick Recap of Covering Indexes

A covering index is an index that contains every column a query needs, so the database can answer from the index alone. In PostgreSQL we often add non-key columns with INCLUDE, and in InnoDB every secondary index already carries the primary key. The trade is simple: reads get faster because they skip the table, and in exchange every write must also update the index, and the index takes disk and memory.

For a narrow index that serves a selective query, such as orders by customer_id, that trade is excellent. The index is small, the query touches a few pages, and the write cost is one extra entry. The trouble starts when the INCLUDE list grows to ten or fifteen columns so that a list page can avoid the table.

SQL
CREATE INDEX orders_customer_list_idx ON orders (customer_id, created_at DESC)
INCLUDE (status, total, currency, shipping_city, item_count, channel, discount, updated_at);
-- a near copy of the orders row, kept sorted a second way

2What Wide Indexes Really Cost

Every index is written on every insert, and on every update that changes one of its columns. With eight wide indexes, one order insert becomes nine writes, each with write-ahead log (WAL), the log the database writes before changing data so it can recover and replicate. More WAL means more replica traffic, larger WAL archives and slower point-in-time recovery.

The storage cost also multiplies. The 1.6 TB of indexes is stored on the primary, on every replica, in every backup and in every restored test environment. With two replicas and 30 days of backups, it is many times 1.6 TB. Memory suffers too: the indexes compete with the table for the buffer cache, so the queries that need the table get slower. And on PostgreSQL, an update that touches any indexed column cannot be a HOT update, the cheaper path that avoids new index entries, so wide indexes also make updates more expensive.

One logical cost, many physical copies
Where the index livesEffect of 1.6 TB of indexes
Primary1.6 TB disk, buffer cache pressure, extra writes per row
WAL and replicasmore log per write, more replica lag, 2 replicas = 3.2 TB more
Backupsevery full backup and restore carries the indexes
Vacuum and maintenanceevery index is scanned in each vacuum pass
The index cost a team sees on one endpoint is a fraction of what the company pays.

3The Other Shapes and What Each Suits

A read model is a separate table or store shaped for one kind of read, kept in sync from the source data. In CQRS, command query responsibility segregation, writes go to the normalised tables and an event consumer updates projections for reads. A list view that shows twelve columns per order is a natural read model: one denormalised table keyed the way the page reads it, updated asynchronously. In the same database, a materialised view or a denormalised summary table can play this role when some staleness is fine.

A cache suits hot, repeated reads of the same result: the same product page or the same customer summary requested thousands of times a minute. The database answers once and the cache serves the rest. An analytics store, a columnar warehouse such as ClickHouse, BigQuery or Snowflake fed by change data capture, suits aggregations over large ranges, such as revenue by region for the last year. Columnar storage reads only the needed columns and compresses well, so these queries are cheaper there than any index can make them in the transactional database.

4Setting Criteria Per Endpoint

We give teams a short decision process instead of a ban. For each slow endpoint we ask how often it runs, what latency it needs, how fresh the data must be, and how many writes the table receives. Selective, frequent, must-be-fresh queries on a moderate write rate stay with an index, preferably narrow. Wide list views that can be seconds old move to a read model. Identical hot reads go behind a cache. Range aggregates move to the analytics store.

Then we make the cost visible. A monthly report per table shows each index's size, scans and estimated cost, and new indexes on very large tables get a short review with the query and plan as evidence. An index that served 50,000 scans a day last year may serve none now. We also revisit decisions, because a read model that made sense at 100 requests per second may be overkill at 5.

Step throughChoosing a shape for a slow endpoint
  1. Selective lookup, few columns, must be fresh?
    YesNarrow index in the OLTP databaseNoContinue
  2. Same result requested again and again?
    YesCache with a short TTLNoContinue
  3. Aggregates over large ranges?
    YesAnalytics store fed by CDCNoContinue
  4. Many columns, list or dashboard viewread model or materialised view, seconds of lag accepted

4 steps in order. Play them, or step through them one at a time.

5Follow-up questions

Is a read model not just another copy of the data, like the wide index?

It is a copy, but a cheaper one. It is written once per change asynchronously, outside the critical write path, and it can live in a different store with its own backup policy and size. A wide index is updated synchronously in the same transaction as every write, is copied to every replica, and slows the primary for all queries. The read model also has one clear owner and purpose, which makes it easy to drop when the endpoint goes away.

How would you start reducing the 1.6 TB?

I would list indexes by size with their scan counts over a full business cycle, drop the ones with no scans after a safety period, merge overlapping ones (an index on (a) is usually covered by one on (a, b)), and trim INCLUDE lists to the columns that queries really read. The biggest endpoints get a proposal for a read model or cache. I would track write latency, WAL volume and storage cost as the outcome, not just the number of indexes removed.

6Conclusion

In this answer, we saw that covering indexes trade write and storage cost for fewer reads, which is a good trade for selective lookups on a few query shapes. Wide covering indexes duplicate much of the table and multiply cost through WAL, replicas, backups and memory. Read models suit wide list and dashboard views, caches suit hot repeated reads, and analytics stores suit large aggregations. A simple per-endpoint decision based on frequency, latency, freshness and write rate, plus regular cost reviews, keeps the choice deliberate.

What to say in the interviewAbout 90 seconds aloud

Open with

I would start by separating the cases where indexes are right from the ones where they are just the nearest tool. An index is the right answer for selective transactional lookups on a small number of query shapes, like orders for one customer, and a narrow covering index is a good trade there.

Then, if they want more

But a wide covering index with ten INCLUDE columns is a second copy of the table that every insert and update has to maintain, and it is multiplied by WAL volume, every replica, every backup and buffer cache pressure. That is how we get 1.6 TB of indexes on 2 TB of data.

For list pages and dashboards with many columns, I would build a read model or a denormalised table updated by an event consumer, accepting a few seconds of lag. For the same result requested over and over, a cache. For aggregations across months of data, an analytics store fed by change data capture.

To make this a company practice rather than my opinion, I would give teams criteria per endpoint, which are frequency, latency target, freshness and write rate, publish a regular report of index size and scan counts per table with an estimated cost, review new indexes on very large tables with plan evidence, and re-evaluate the decisions every few quarters because traffic changes.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Teams keep adding wide covering indexes to make specific API endpoints fast, and a 2 TB...": https://scrivio-interview-library.netlify.app/databases/indexing/9b6df178d7/