Pick a depth. Each prompt opens in your AI pre-loaded with the lesson. Click a row to preview the prompt.
You will break this lab, and that is fine — it is what a lab is for. Several modules ask you to create indexes, change server settings and deliberately bloat a table, and at some point you will want to get back to the known starting state rather than wondering whether a leftover index is why a plan looks wrong. A reset that takes one command makes experimentation cheap, and cheap experimentation is most of how this material is actually learned. The second half of this task is the troubleshooting list: seven failures account for nearly everything that goes wrong here, each has a distinctive symptom, and knowing them turns a lost afternoon into a two-minute fix. Most of them are not really database problems at all — they are environment problems wearing a database error message.
The reset script, then the seven failures with the exact symptom each produces and the fix, written so you can match an error message to a cause quickly.
# reset.sh — back to the known starting state.
#
# $ ./reset.sh # drop indexes, keep the data (fast)
# $ ./reset.sh --full # drop everything and reseed (slow)
set -euo pipefail
set -a && source .env && set +a
if [ "$1" = "--full" ]; then
echo "dropping and reseeding at SCALE=$SCALE"
psql "$PG_URL" -qf schema.sql
mongosh "$MONGO_URL" --quiet schema.js
node seed.js
exit 0
fi
# Fast path: drop every index except the primary keys, and clear the
# accumulated statistics so the next measurement starts clean.
echo "dropping non-primary indexes"
psql "$PG_URL" -qtAc "
SELECT 'DROP INDEX IF EXISTS ' || indexname || ';'
FROM pg_indexes
WHERE schemaname = 'public' AND indexname NOT LIKE '%_pkey'
" | psql "$PG_URL" -q
psql "$PG_URL" -qc "SELECT pg_stat_statements_reset()" > /dev/null
psql "$PG_URL" -qc "SELECT pg_stat_reset()" > /dev/null
psql "$PG_URL" -qc "ANALYZE users, orders, events" > /dev/null
mongosh "$MONGO_URL" --quiet --eval '
["users","orders","events"].forEach(c => {
db[c].getIndexes()
.filter(i => i.name !== "_id_")
.forEach(i => { db[c].dropIndex(i.name); print("dropped " + c + "." + i.name); });
});
db.setProfilingLevel(0);
db.system.profile.drop();
db.setProfilingLevel(1, { slowms: 200 });
["users","orders","events"].forEach(c => db[c].getPlanCache().clear());
'
echo "reset complete — re-run baseline.sh to confirm"