PostgreSQL & Databases
Partition pruning
Partition pruning lets the planner skip child tables whose bounds cannot match a query's WHERE clause. The filter must compare the partition key directly, or the planner scans every partition.
What you will be able to do
- Explain how the planner uses partition bounds to skip children.
- Decide how to rewrite a filter so pruning works for a date-range query.
What is in the lesson
- A real situation where this goes wrong
- How it works, step by step
- A walkthrough with commands you can run
- How it fails in production, and how to tell
- Three quiz questions with explanations
Read this lessonFree. No account needed.
More in PostgreSQL & Databases
- PITR with pgBackRestAdvanced · 5 min
Point-in-time recovery rebuilds a database to a chosen moment from a base backup and archived WAL. A restore is only as good as the archive that covers the target time.
- PgBouncer transaction poolingAdvanced · 5 min
PgBouncer transaction pooling lends a server connection for one transaction at a time. Session state set outside a transaction can leak to other clients, so the…
- Schema migration safetyAdvanced · 5 min
Many ALTER TABLE forms take a strong lock that blocks reads and writes while they wait. Safe migrations set lock timeouts, check for open transactions, and build…
- Composite index ordering: operational verificationAdvanced · 5 min
A composite B-tree index is sorted by its leading column first, so queries that constrain the leading columns use it best. Column order also decides whether a sort can…
- Partial indexes: failure analysisAdvanced · 5 min
A partial index covers only rows that match its predicate. The planner uses it only when it can prove the query's condition implies that predicate, which is often lost…
- Index only scans: operational verificationAdvanced · 5 min
An index-only scan answers a query from the index, but it still reads table pages that the visibility map does not mark as all-visible. Heap fetches show how much table…