← Back to topic library
Dev MaxxingIntermediateDatabases75 sec
Database index
A database index is a separate structure built on one or more columns that lets the database find matching rows much faster than scanning the whole table.
Prerequisite: SQL query
What matters
Without an index on a column used often in searches, the database may have to check every row one by one, which becomes slow as a table grows large.
Example
Adding an index on a 'users' table's 'email' column lets a lookup by email skip scanning every row, checking only the indexed structure instead.
Common misconception
Adding more indexes is not always better; each index speeds up matching reads but adds overhead to every write, since the index must be updated too.
Recall question
Why does a database index speed up lookups on the columns it covers?
Keywords and related concepts
database indexquery performancelookup speedsql query