9. Indexes
Interview questions
Interview questions (with the counter-questions you'll get)
Q1. What is a database index, and how does it speed up queries?
They're testing: a correct mental model.
Think about your answer first, then open it.
Q2. How does a B-tree index work?
They're testing: depth.
Think about your answer first, then open it.
Q3. B-tree vs hash index vs LSM tree?
They're testing: matching structures to workloads.
Think about your answer first, then open it.
Q4. Explain composite indexes and column order.
They're testing: the leftmost-prefix rule.
Think about your answer first, then open it.
Q5. What is a covering index?
They're testing: a common optimisation.
Think about your answer first, then open it.
Q6. A query is slow. How do you investigate?
They're testing: a methodical approach.
Think about your answer first, then open it.
Q7. Why might the database not use an index you created?
They're testing: planner awareness.
Think about your answer first, then open it.
Q8. What's the cost of indexes?
They're testing: trade-offs.
Think about your answer first, then open it.
Q9. How would you index a column for "contains" text search?
They're testing: knowing B-tree limits.
Think about your answer first, then open it.
Q10. How does indexing differ for a write-heavy table, like events?
They're testing: workload thinking.
Think about your answer first, then open it.