🗂️Database Indexing Explained
Stop adding indexes by trial and error and start designing them from first principles — see why B-trees beat full scans for range queries, read EXPLAIN plans like a pro, and index a real schema without slowing down every write.
Phase 1How B-Trees Actually Work
See why B-trees rule reads and what they cost on writes
An index is a phone book your database can binary-search
6 minAn index is a phone book your database can binary-search
B-trees are tree-shaped binary search, not regular trees
7 minB-trees are tree-shaped binary search, not regular trees
Sorted leaves are why ranges and ORDER BY come free
6 minSorted leaves are why ranges and ORDER BY come free
Indexes only help when they cut the haystack down hard
7 minIndexes only help when they cut the haystack down hard
Phase 2Adding Indexes and Measuring with EXPLAIN
Add indexes to slow queries and prove it with EXPLAIN
EXPLAIN tells you what the database is going to do
7 minEXPLAIN tells you what the database is going to do
The first index to add is on the WHERE clause column
6 minThe first index to add is on the WHERE clause column
An index that holds every column the query needs is a free win
7 minAn index that holds every column the query needs is a free win
Index only the rows that matter and skip the rest
7 minIndex only the rows that matter and skip the rest
Index the function output, not the column
7 minIndex the function output, not the column
Phase 3Composite Indexes Match WHERE Clauses
Order composite-index columns to match real WHERE clauses
Column order matters more than you think
7 minColumn order matters more than you think
An index on (a, b, c) can serve any leftmost prefix
7 minAn index on (a, b, c) can serve any leftmost prefix
Once you hit a range, the rest of the index can't filter
7 minOnce you hit a range, the rest of the index can't filter
Indexes age — measure them, drop the dead ones
7 minIndexes age — measure them, drop the dead ones
Phase 4Index a Real Schema Without Over-Indexing
Index a real schema end-to-end without over-indexing
Index a real schema and defend every index you add
8 minIndex a real schema and defend every index you add
Frequently asked questions
- What is a database index in plain English?
- This is covered in the “Database Indexing Explained” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
- How does a B-tree index actually speed up queries?
- This is covered in the “Database Indexing Explained” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
- When should I use a composite index versus separate indexes?
- This is covered in the “Database Indexing Explained” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
- Why does adding more indexes slow down writes?
- This is covered in the “Database Indexing Explained” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
- How do I read an EXPLAIN plan to know if my index is being used?
- This is covered in the “Database Indexing Explained” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
Related paths
🐍Python Decorators Introduction
Build one mental model for Python decorators that covers closures, argument passing, functools.wraps, and stacking — then ship a working caching or logging decorator from scratch in under 30 lines.
🦀Rust Lifetimes Explained
Stop reading `'a` as line noise and start reading it as scope arithmetic — one failing snippet at a time — until you can thread lifetimes through a small parser or iterator adapter without fighting the borrow checker.
☸️Kubernetes Core Concepts
Stop drowning in 30+ resource types. Build the mental model one primitive at a time -- pods, deployments, services, ingress, config -- then deploy a real app with rolling updates and health checks.
📈Big O Intuition
Stop treating Big O as math you memorized for an interview — build the intuition to spot O(n²) disasters, pick the right data structure without thinking, and rewrite a slow function from O(n²) to O(n) in under five minutes.