BolEnglishLearn · Play · Win
Login

📑 Data & Database Design · Data & Databases

📑

Indexing

Data ConceptIntermediateModule 4

Create structures that help the database find data faster.

An index is like a book index: it avoids scanning every page.

💡 In practice

Index Email when users frequently search customers by email.

🖼️ CONCEPT PICTURE
A picture to help remember Indexing
Index Email when users frequently search customers by email.

💡 An index is the alphabetical tab list at the side of an address book — you jump straight to "S" instead of reading every name.

💡 Learn🛠️ Apply🎯 Check

💡 Why it matters

As tables grow, searching every row for a match gets painfully slow. An index lets the database jump near the answer instead of scanning everything. Good indexes turn slow queries into fast ones, but each index costs a little extra work on every write, so they are chosen, not sprinkled everywhere.

🛠️ How to achieve it

1
Index what you search by
Add indexes on the columns used in frequent lookups and joins, like Email or CustomerId.
2
Match the index to the query
The column order in a multi-column index should mirror how queries filter and sort.
3
Do not over-index
Every index slows inserts and updates slightly, so keep only the ones that earn their place.
4
Measure the effect
Check the query plan before and after to confirm the index is actually being used.

⚠️ Signs of trouble

  • •Searches crawl as the table gets bigger.
  • •The database scans the whole table for a single row.
  • •Writes slow down because of too many unused indexes.
  • •Common lookups have no index backing them.
⚠️ Common mistake: Adding an index to every column "just in case". Index the columns your real queries search and join on, and remove indexes nothing uses.

🎯 Quick check

Score: 0/3

Three questions to test the idea.

  1. 1. What does an index help the database do?

    Answer: Find matching rows without scanning every row

    An index lets the database jump near the answer, avoiding a slow scan of the whole table.

  2. 2. What is a cost of adding many indexes?

    Answer: Each one slows inserts and updates a little

    Every index must be kept up to date on each write, so too many indexes slow down inserts and updates.

  3. 3. When should you index a column like Email?

    Answer: When users frequently search by it

    Index the columns real queries filter or join on. If users often search by email, an index on Email pays off.

🔑 Key terms

Index
A lookup structure that speeds up finding rows.
Full table scan
Reading every row because no index helps.
Query plan
The database's step-by-step plan for answering a query.
Composite index
An index covering more than one column together.

✅ Review checklist

📊 Your progress

0%
Mark this topic learned to track it.
Saved in this browser.
🚀 Got it?
Mark it learned and move to the next topic.
Next topic →