Seq Scan vs. Index Scan — Query Plan Comparison

Table orders: 10M rows, 100,000 pages. Composite index on (customer_id, created_at DESC). Toggle the index and change LIMIT to see the plan and cost change.

SELECT * FROM orders WHERE customer_id = 42 ORDER BY created_at DESC LIMIT 20;

Access Path: Index Scan (B-tree)

Plan Comparison (cost = page reads)

Toggle the index, set LIMIT, then press Step or Auto-play.