Indexes: Finding Rows Fast
Without help, finding one customer among a million rows means reading them all. An index is a separate sorted structure (like the index at the back of a book) that lets the database jump straight to matching rows.
Index the columns you search, join and sort by often. The trade-off: every index uses space and must be updated on each insert, update and delete, so do not index everything. A UNIQUE index also enforces uniqueness. Primary keys are indexed automatically.
What is the trade-off of adding an index?
Create an index named idx_name on column name of t, then print the names of the indexes on the table as a sorted list (PRAGMA index_list returns the name in the second column).
Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.
Tip: use the left and right arrow keys to move between lessons.