# Database Index

> A sorted list that lets the database find rows fast. It skips the rest.

**Field:** Software Development  
**Category:** Databases  
**Also known as:** Index, SQL Index, Table Index

## Think of it like

Think of it like the index at the back of a book. You jump to the right page instead of reading it all.

## Definition

A database index is a sorted list that helps the database find rows fast. Without one, it must read every row to find a match, which is called a full scan. With one on the right column, it jumps straight to the rows it needs. Indexes make reads much faster but writes a little slower, because each one must be kept up to date. Primary keys get an index on their own.

## Example

Jack's orders table grows to 2 million rows and the search page takes 4 seconds. An index on the email column brings it under 10 milliseconds.

## Example code

```sql
EXPLAIN QUERY PLAN SELECT * FROM customers WHERE city = 'London';
-- SCAN customers
CREATE INDEX idx_city ON customers(city);
EXPLAIN QUERY PLAN SELECT * FROM customers WHERE city = 'London';
-- SEARCH customers USING INDEX idx_city (city=?)
```

In SQLite, the scan of every row becomes a search of the index.

## Why it matters

When a big database gets slow, a missing index is most often why.

## Common mistake

Adding an index on every column. Each one slows down writes and takes space, so add them where queries need them.

## Three principles

- **Jump, do not scan.** Find rows without reading all.
- **Faster reads.** But a little slower writes.
- **Pick the columns.** Index what you search on.

## Related terms

- [Database Query](https://learn.benibix.com/term/development/query)
- [Primary Key](https://learn.benibix.com/term/development/primary-key)
- [Database](https://learn.benibix.com/term/development/database)
- [Query Plan](https://learn.benibix.com/term/development/query-plan)

---

Source: https://learn.benibix.com/term/development/database-index
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
