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
- Read the training contract.
- Set up the project with the fast
testdataset. - Learn the local Docker workflow, including PostgreSQL, pgAdmin, and this documentation site.
- Review the progressive curriculum.
- Complete Lab 01 — Establish the Baseline.
- Use the operations guide while gathering evidence.
- Complete each knowledge-check quiz before advancing.
Mental model
- 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.