Falling in Love with SQL
summary
Shows how real queries against a 90+ million rows books table drop from 3.6 seconds to 0.1 milliseconds by switching from a full table scan to a composite index on (publisher, title) and using ordered index reads. Demonstrates the failure of a single-column index for high-cardinality publishers with 2 million books, explains CTE plus cross join lateral to force per-publisher top N and avoid gigantic sorts, covers merge joins and the planning cost explosion for many CTEs, and warns that indexes slow writes and consume space.
AI-written summary · about
chapters (8)
- 0:00Introduction
- 1:15Why SQL Dominates Web Performance
- 3:37How B-Tree Indexes Work
- 8:32Optimizing Ordered Lookups with Composite Indexes
- 13:12Multi-Publisher Queries with CTEs and Lateral Joins
- 18:38Indexed Joins and Merge Joins
- 22:11Index Costs and Deliberate Indexing
- 23:40Q&A: A Production Over-Indexing Incident
