Level 1: Bronze
A memorized definition. Not wrong, but it stops there.
It makes searches faster.
3 stars If you are short on time, start with this one.
In one or two sentences
An index is a separate structure that lets the database find rows without reading the whole table. The cost is slower writes and extra storage.
Say it out loud, or type it below. What you type never leaves this device.
A memorized definition. Not wrong, but it stops there.
It makes searches faster.
Correct, but too broad or missing context.
Like a book index, it keeps values sorted with their locations so matching rows are found quickly. It takes space and makes writes slower.
Reaches principle, use and trade-off, with words that invite the next question.
The common implementation is a B-tree. It is sorted, so it serves equality, range conditions and ordering. Every change to a row also updates the index, so index only columns that are read a lot. A composite index helps only when the leading columns appear in the condition, and a column with few distinct values filters weakly, so the optimizer may skip it. Wrapping a column in a function can also defeat the index. Check whether it was used in the execution plan.
These are likely next questions from an interviewer. Think of your answer first, then press the button.
1 / 3
Why does column order matter in a composite index?
It is sorted by the leading column first, so without a condition on it the index is hard to use efficiently.
2 / 3
When does an index exist but not get used?
When the column is wrapped in a function or expression, when the filter is weak and a full scan is cheaper, or when a type mismatch forces a conversion.
3 / 3
What is a covering index?
An index that holds every column the query needs, so the answer comes from the index alone without reading the table.