Day 6 of 45 · SQL Masterclass · Free

Day 6: SQL Performance

Profile slow unindexed queries on 100,000 orders and refactor them to execute under 10 milliseconds.

About 60 minutes of learning and 90 minutes of practice. It runs in your browser, with no install.

What you will be able to do

  • Read and interpret EXPLAIN and EXPLAIN ANALYZE query plans to identify full table scans and memory spills.
  • Write SARGable WHERE clause predicates that leverage database indexes and partition pruning.
  • Restructure queries to pre-aggregate high-cardinality tables before expensive multi-table joins.

What the day covers

indexes, query plans, EXPLAIN, EXPLAIN ANALYZE, partitioning, clustering concepts, predicate pushdown, avoiding SELECT *, joins and cardinality, materialized views.

What you build

Deliberately write a slow query, then optimize it.

Questions you should be able to answer afterwards

  • What does SARGable stand for and why does wrapping an indexed column in a function break it?
  • What is the difference between EXPLAIN and EXPLAIN ANALYZE?
  • Why should you pre-aggregate a 10M-row order_items table before joining it to a customers table?

Practice this day's skills

Each page shows the idea moving, then lists problems from easiest.

Builds on Day 5.

Days 1 to 7 are free. Days 8 to 45 need a pass; the plan page lists what each day covers, and the glossary defines each term.