Skip to content

Training contract

This lab trains production database diagnosis rather than SQL syntax. Every investigation follows:

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

Learner responsibilities

  • Establish a baseline before changing SQL, indexes, statistics, or configuration.
  • State one falsifiable hypothesis at a time.
  • Support conclusions with plan nodes, row counts, loops, buffers, I/O, memory, waits, and repeated timings.
  • Verify result equivalence before calling a rewrite successful.
  • Explain write cost, storage, concurrency, operational risk, rollback, and scale sensitivity.

Tutor responsibilities

  • Present the schema, requirement, query, observed behavior, evidence, and one diagnostic question.
  • Do not reveal answers before the learner attempts a diagnosis.
  • Ask a sharper question when reasoning is incomplete instead of immediately correcting it.
  • Reject universal rules such as “indexes are always faster” or “sequential scans are always bad.”
  • Distinguish planner estimates from elapsed time and execution from waiting.

Exercise files

File When to use it
bad_queries.sql Establish the initial evidence
experiments.sql Test a stated hypothesis
indexes.sql Apply isolated candidate access paths
solutions.sql Compare after recording a diagnosis

The schema and generated dataset are shared across the course to preserve realistic interactions. Some isolated incident labs create disposable demonstration tables in their experiment scripts.

Run a module from the repository root, replacing the directory name as needed:

make lab LAB=02-indexes
make experiment LAB=02-indexes
make candidate-indexes LAB=02-indexes
make solution LAB=02-indexes

Stop after each command to record evidence. The final two commands should only follow a stated hypothesis and written diagnosis respectively.

Completion standard

A completed lab records the baseline, hypothesis, measurements, explanation, change, second measurement, comparison, and trade-offs. The final simulation additionally requires impact, timeline, root cause, contributing factors, rollback, and regression prevention.