Skip to content

Lab 09 — Partitioning

Scenario

A recent-activity query counts events from the last day. This lab evaluates whether partition pruning can reduce the data considered and whether partitioning is justified operationally.

Run the exercise

make shell
\i sql/labs/09-partitioning/bad_queries.sql

Investigate

  1. Record the current scan, rows filtered, and buffers.
  2. Inspect the time distribution and total size of customer_activity.
  3. Propose a partition key and interval aligned with retention and queries.
  4. Explain static or runtime pruning evidence you would expect.
  5. Account for migration, index duplication, vacuum, and partition lifecycle costs.

Diagnostic question

Would partitioning materially reduce work for this dataset, or would a simpler access path meet the requirement with less operational cost?

Previous: Pagination · Next: Incidents