Indexing Strategy and Design Questions
Choosing and designing indexes: B-tree, hash, composite, covering, and partial indexes, and the trade-offs between read acceleration and write/storage overhead. Covers selecting index columns from query patterns, cardinality and selectivity reasoning, and diagnosing why an index is or is not used. Central to database performance interviews.
You discover that queries against a large fact table are slowed by many small index range scans due to low selectivity predicates. Explain alternatives (covering indexes, composite indexes, bitmap indexes where supported, and architecture-level solutions like OLAP replicas) and how you'd choose between them.
You are given a query that runs slowly: it filters on LOWER(email) = 'abc@example.com'. Explain why this may prevent index usage and propose alternatives to make lookups case-insensitive while remaining sargable. Include SQL examples and index recommendations for PostgreSQL.
Describe how to detect redundant or unused indexes in PostgreSQL using system catalogs and query statistics. What metrics would you inspect before dropping an index, and how would you safely validate that dropping it has no negative impact?
List common index types (e.g., B-tree, hash, GIN/GIST) and explain use-cases for each. For example, when would you use a B-tree vs a hash index vs a GIN index? Mention important limitations or platform-specific caveats (e.g., Postgres hash index behavior historically).
Explain the difference between clustered and non-clustered indexes. For each: describe internal structure, typical use-cases, and how they affect read and write performance. As a data analyst, when would you recommend creating a clustered index on a table used by dashboards?
Unlock Full Question Bank
Get access to all 6 Indexing Strategy and Design interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.