Skip to content
>devspeak
← glossary
level 4Databases

Index

also: indexes, indices, indexed, database index

A shortcut the database keeps so it can find matching data fast, instead of checking every entry one by one.

a bit more technical

A separate data structure, often a B-tree, built on one or more columns so the database can locate matching rows without scanning the whole table. Indexes speed up reads but use storage and slightly slow down writes.

picture it

The index at the back of a cookbook. To find every recipe with lemon, you check the index and jump to the right pages, instead of reading the whole book.

why it matters

When a page slows down as your data grows, a missing index is one of the most common causes. Agents often propose adding one. Now you'll know what that means and why it's usually a fairly safe change.

what your agent might say
agent
The query on bookings.customer_id is doing a full table scan. Adding an index on that column should make it much faster.
how you might use it
you → your agent
The orders page got slow. Check whether its queries are missing an index, and explain the tradeoff before adding one.
common mistake

Thinking more indexes are always better. Each one costs storage and makes every insert and update a little slower. Add them where real queries need them.

builds on