Skip to content
Minute Campus.

Interview questions, answeredLesson 021 min

Interview question: what does a database index do?

An index lets a database find rows by one column without reading the whole table. Without one, searching 100,000 customers for an email means a full table scan, which SQLite's documentation says one normally tries to avoid. An index is a separate table sorted by the searched column, so the plan changes to a search. The cost is extra space.

Remember

Index the columns you search on, not every column.

Sources

Checked at the source.

Every claim in the lesson was checked against these before it was recorded.

  1. 1The Query PlannerSQLite documentation · read 14 Nov 2026A full table scan reads the whole table; an index is a new table sorted by the indexed column, allowing binary search.
  2. 2CREATE INDEXSQLite documentation · read 14 Nov 2026Describes the command that creates an index on a table's columns or expressions.

Transcript

The lesson, word for word.

Read it at your own pace, or search the page for a term.

Interview question: what does a database index do? The answer has two halves: what it gives you, and what it costs. Imagine a table with one hundred thousand customers, and you search for one email address. Without an index, the database has to read every row. SQLite's documentation calls this a full table scan, and says one normally tries to avoid it. An index is a separate table, sorted by the column you search on, so the database can search it quickly. Run the same query after creating the index, and the plan changes from a scan to a search using the index. The catch: the index is a second table, so it takes space too. Model answer: an index lets the database find rows by one column without reading the whole table, at the cost of extra space. Index the columns you search on not every column.

Questions? Comment on the lesson on YouTube

New lessons every day.

Follow Minute Campus where you already scroll.