
What Happens When You Run a SQL Query? (Zero to Pro)
You type a SQL query, hit run, and rows appear half a second later. What actually happens in between? This video breaks down the entire query execution pipeline from zero to pro — from raw SQL text to rows on your screen. We cover parsing SQL into a parse tree, binding names against the catalog, how the query optimizer generates candidate plans, cost-based optimization using table statistics, choosing physical operators (table scan vs index scan, nested loop vs hash vs merge join), the execution engine's iterator model, the storage engine's buffer pool and B-tree indexes, and how transactions use locks/MVCC plus a write-ahead log to stay consistent and durable. TIMESTAMPS 0:00 Intro — What Happens When You Run a SQL Query? 0:10 Step 1: SQL → The Parse Tree 0:31 Step 2: Binding & the Catalog 0:52 Step 3: The Query Optimizer 1:10 Step 4: Costed by Statistics 1:32 Step 5: Choosing Physical Operators (Scans & Joins) 1:52 Step 6: The Execution Engine 2:13 Step 7: Storage Engine (Buffer Pool & Indexes) 2:32 Step 8: Transactions (Locks, MVCC & WAL) 2:53 The Full Pipeline Recap If this helped you understand what's happening under the hood, consider subscribing for more deep dives like this.