Skip to content

SQL Performance Lab

A production-shaped PostgreSQL e-commerce laboratory for learning performance diagnosis from evidence rather than recipes.

Training contract

Every investigation uses:

Observe → Hypothesize → Measure → Explain → Change → Measure again → Compare → Trade-off

Do not inspect a lab's solutions.sql until you have written a diagnosis. A sequential scan is not automatically bad, an index is not automatically useful, and planner cost is not elapsed time.

Start here

  1. Read the training contract.
  2. Set up the project with the fast test dataset.
  3. Learn the local Docker workflow, including PostgreSQL, pgAdmin, and this documentation site.
  4. Review the progressive curriculum.
  5. Complete Lab 01 — Establish the Baseline.
  6. Use the operations guide while gathering evidence.
  7. Complete each knowledge-check quiz before advancing.

Mental model

SQL → Parser → Rewriter → Planner/Optimizer → Plan → Executor → CPU/Memory/Storage
  • The parser validates syntax and builds a parse tree.
  • The rewriter applies rules and expands views.
  • The planner estimates cardinalities and costs candidate paths.
  • The executor runs the selected operators.
  • Buffers, memory, storage, locks, and CPU determine observed behavior.

Repository layout

Path Purpose
sql/bootstrap Schema, scale-aware seed, and dataset report
sql/indexes Intentionally imperfect baseline indexes
sql/labs Progressive investigations and exercises
sql/final Unspoiled capstone incident
docs Browser documentation and operating guidance

Production safety

EXPLAIN ANALYZE executes its statement. Do not copy lab commands to production without reviewing their side effects. The reset workflow is intended only for this disposable lab database.