Add lesson 30: Index types beyond B-tree#89
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
…t scale Grows docs from ~40k to ~5,000,000 rows (seed-once base branch). At that size the old demos regressed to Seq Scans, so distributions were fixed so each index genuinely wins: rare 'gin' tag / 'report' kind (~1%), a rare 'pinned' key for the GIN ? existence demo (the old 'priority' key was on every row -> always a Seq Scan), ~50k distinct emails and ~500k owners. Moved the hash demo to email (a truer wide-key example) so the covering index is the sole owner_id index and yields a real Index Only Scan. No VACUUM (the seed runs as one implicit transaction; high owner cardinality gives the Index Only Scan instead). All 7 demos verified on Postgres 16. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
query-returns check confirms the learner built the GIN index on tags via pg_indexes matching 'gin (tags' — robust to naming, ignores the meta GIN. Verified on PG16 (0 before, 1 after). 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 third lesson of Module 7: Performance & indexing — index types beyond B-tree (roadmap item
30-index-types).What's in the lesson
Each with a when-to-use, a cost note, a
CREATE INDEX, and a query it accelerates:@>,?), arrays (@>,<@,&&),tsvector(@@)&&), spatial, KNN (<->), exclusion constraintscreated_at)CREATE INDEX … WHERE …… (lower(email))INCLUDEfor Index-Only Scanspg_trgmis mentioned only as an out-of-scope extension (the sandbox is core-only).Seed
A
docstable (~40k rows viagenerate_series) withjsonb,text[], a skewedstatus, mixed-caseemail, and time-orderedcreated_atso every index type is demonstrable; ends withANALYZE.Checks
One
query-returnscheck (tags-gin-created): confirms the learner built the GIN index ontagsby queryingpg_indexesfor a definition matchinggin (tags— robust to the index name and ignoring themetaGIN. Verified on PG16 (0 before, 1 after).Notes
Includes the byte-identical Module 7
module.yaml.npm run lessons:validateandnext buildboth pass.Part of #6
🤖 Generated with Claude Code