What is a database index and what are the trade-offs of adding one?

technical-conceptual · Junior level · software-engineering

What the interviewer is really asking

Assesses whether the candidate understands that performance optimizations have costs — a critical engineering judgment.

What to say

What to avoid

Example answers

Strong: On a users table with 10M rows, a query like WHERE email = ? without an index does a full table scan — O(n). Adding an index on email makes it O(log n). The trade-off is every INSERT or UPDATE to email now also updates the index.

Weak: I'd index every column up front — storage is cheap and you never know which columns you'll query later.

Want questions matched to your role? Paste a job title, job description, or CV and get a personalized set, or go Pro to unlock the full bank.