How Database Indexes Work: B-tree vs Full Scan in SQLite
200,000 rows: one CREATE INDEX turned a full scan into a search, same answer.
Video #276 ยท How it works, by example
Steps in the video
Files
- make_db.py (16 lines)
- plan.py (19 lines)
- run.py (21 lines)
- steps.py (14 lines)
Tested with
Python 3.12.15
What this does not show
Made-up orders in an in-memory SQLite database, so no disk reads; the speed-up is shown only as a floor, and the space and write cost of the index was not measured.
Sources
Learning IT by Example.