# SQL Level 10: Indexes & Query Planning

> Level 10: Indexes & Query Planning of the LoWisa SQL course: Index Structures, Query Execution Plans, Diagnosing Slow Queries. 3 lessons and 9 ideas, each explained in one line.

Indexes & Query Planning is level 10 of 15 of the [LoWisa SQL course](/courses/sql/). It has 3 lessons and 9 ideas. Below is every lesson and what it teaches, in one line each.

## Index Structures

- **B-tree indexes.** A **B-tree** index is a sorted structure over a column: equality and range lookups stop scanning the table.
- **Composite indexes.** A **composite** index on (customer_id, created_at) serves the pair: leftmost columns first is the law.
- **The write cost.** Every index taxes every **write**: indexes are bought with insert and update speed, so each must earn its place.

## Query Execution Plans

- **EXPLAIN.** **EXPLAIN** shows the plan: scans, index usage, join strategies and cost estimates: the query’s X-ray.
- **Scans versus seeks.** A sequential **scan** reads everything; an index scan jumps to matches: which is right depends on selectivity.
- **Join strategies.** Engines choose nested loops, hash or merge **joins**: the plan names which, and row estimates explain why.

## Diagnosing Slow Queries

- **Measure real timing.** EXPLAIN **ANALYZE** runs the query and reports true times per node: estimates checked against reality.
- **Bad estimates.** Most slow plans trace to stale **statistics**: the planner guessed a thousand rows and got ten million.
- **The usual fixes.** The fix ladder: better **index**, rewritten predicate, refreshed statistics, then schema change: cheapest first.

## Before and after this level

- **Before:** [Level 9: Transactions](/courses/sql/level-9-transactions/): ACID, Isolation and Concurrency, Locks, Deadlocks and Transaction Design.
- **Next:** [Level 11: Advanced SQL](/courses/sql/level-11-advanced-sql/): Recursive Queries, Advanced Grouping and Set Operations, Complex Relational Patterns.

In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See [Checkpoints and flashcards](/help/checkpoints-and-flashcards/).

## Frequently asked questions

### What does SQL Level 10: Indexes & Query Planning cover?

Index Structures, Query Execution Plans, Diagnosing Slow Queries: 3 lessons and 9 ideas.

### What should I know before this level?

The level before it, Level 9: Transactions, which covers ACID, Isolation and Concurrency, Locks, Deadlocks and Transaction Design.

## Learn SQL on your phone

The first level is free. LoWisa is on Google Play and the App Store.

---

Source: https://lowisa.dev/courses/sql/level-10-indexes-and-query-planning/ · Updated 2026-11-16
