Databases and storage · Concept

Indexes

A sorted lookup structure a database keeps beside a table, like the index at the back of a book, so it can find rows without reading every one.

Keeping data correct · updated

How it works

Without an index, finding orders by customer means scanning the whole table. With an index on customer_id the database jumps straight to the matching rows. A composite index covers several columns in a set order, and a unique index doubles as a rule that no two rows may share a value.

Indexes are not free: each one takes storage and slows inserts and updates a little. The EXPLAIN command shows whether a query actually uses one. Adding the right index is often the single biggest speed-up for a slow page.

More in Databases and storage

Keeping data correct

All 25 Databases and storage terms

Crafted in the dark. Shipped to the world.

Tell us what you are building. You get a private project space with a proposal and a line-by-line quote within a day.