Add lesson 29: Reading EXPLAIN#88
Merged
Merged
Conversation
Part of #6 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
43 tasks
…isks The first Run block had two count(*), and Markdown paired the asterisks as emphasis, so the shell received count() and Postgres rejected it (42809). Escaped both as count(\*) per the >=2-asterisks run-block rule; verified the rendered SQL now contains count(*). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
New 'Your turn': learner uses EXPLAIN to see status='cancelled' do a Seq Scan, adds the orders(status) index, and confirms the plan flips to a Bitmap Index Scan; a query-returns check on pg_indexes verifies the index (0 before, 1 after, verified on PG16). Also corrects the earlier section, which wrongly claimed 'cancelled' already used an index-style plan — without a status index it is a Seq Scan; reworded to compare row estimates and foreshadow the capstone. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the second lesson of Module 7: Performance & indexing — reading EXPLAIN (roadmap item
29-explain).What's in the lesson
EXPLAIN(plan only) vsEXPLAIN ANALYZE(actually runs the query) — with a write-safety warning (BEGIN … ROLLBACK)cost=startup..total rows width) and, with ANALYZE,actual time/rows/loopsANALYZE/ autovacuumEXPLAIN (ANALYZE, BUFFERS), plusVERBOSE/SETTINGS/FORMAT JSON; planning vs execution timeSeed
Two related tables via
generate_series(~4kcustomers, ~40korders) with an index andANALYZE. Illustrative plan output lives in fenced blocks (numbers vary per run); learners run the realEXPLAINs.Checks
One
query-returnscheck (status-index-created): a closing diagnose-fix capstone has the learner spot thestatus='cancelled'Seq Scan, add theorders(status)index, and watch the plan flip to a Bitmap Index Scan; the check confirms the index viapg_indexes(0 before, 1 after, verified on PG16). This also corrected an earlier line that wrongly claimedcancelledalready used an index-style plan (no status index existed, so it was a Seq Scan).Notes
Includes the byte-identical Module 7
module.yaml.npm run lessons:validateandnext buildboth pass.Part of #6
🤖 Generated with Claude Code