Indexing Strategy and Design Questions

Choosing and designing indexes: B-tree, hash, composite, covering, partial, and full-text/inverted indexes, and the trade-offs between read acceleration and write/storage overhead. Covers selecting index columns from query patterns, cardinality and selectivity reasoning, diagnosing why an index is or is not used, and index maintenance: rebuilding or reorganizing a fragmented index, finding and dropping redundant or unused indexes, and rolling out a new index to production safely. Also covers indexing in analytical (bitmap, columnar), partitioned, and distributed/NoSQL systems. Central to database performance interviews.

EasyTechnical
58 practiced

As a data engineer you observe that bulk inserts to table logs slowed significantly after adding several indexes. Describe immediate steps you would take to diagnose and mitigate insert slowdown without losing required indexes permanently.

HardSystem Design
67 practiced

You're building on a NoSQL key-value store that has no native secondary-index feature, and the application needs to look up records efficiently by an attribute other than the primary key. Design an indexing approach that supports this at scale, and explain the consistency, write-amplification, and hot-key risks your design introduces as write volume grows.

EasyTechnical
43 practiced

Given a table events(event_id PK, user_id int, event_type text, occurred_at timestamptz), write SQL (Postgres syntax) to create a composite index to efficiently support queries like:

SELECT * FROM events WHERE user_id = ? AND occurred_at >= ? ORDER BY occurred_at DESC LIMIT 50;

Explain the choice and column order for the composite index.

EasyTechnical
43 practiced

Explain the difference between an index scan (index seek) and a sequential scan. Given an example query that filters on a non-indexed column and takes 30s, how would you explain to a non-technical stakeholder why adding an index might reduce report latency?

MediumTechnical
45 practiced

Explain how database statistics and histograms influence the optimizer's choice of index or join order. How would you diagnose and fix a query that does a full table scan due to stale or absent statistics?

Unlock Full Question Bank

Get access to all Indexing Strategy and Design interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.