BeginnerCoder

Lesson 10 — Indexes (concept)

Indexes: a table of contents for a column

Without help, WHERE email = '...' must read every row (a full scan). An index is a separate sorted structure that lets the database jump straight to matching rows, like a book's index. You create one on the columns you search by often. SQLite keeps a list of all tables and indexes in a built-in table called sqlite_master.

CREATE INDEX idx_books_isbn ON books(isbn)

Indexes speed up reads but make writes slightly slower and take space — so add them where queries need them, not everywhere.

Why it matters: the difference between a 2-second and a 2-millisecond page is often one missing index.

Want it another way?
Task

Write the CREATE INDEX statement for users(email). The program then lists the indexes and runs a lookup.

Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.