0Pricing
Advanced PostgreSQL: Indexing, Partitioning, Replication · Lesson

Range Partitioning by Time

Learn how to partition large tables by time ranges to keep recent data fast and archive old data efficiently.

Why Range Partitioning

Range partitioning splits a table into chunks based on a continuous value, most often a date or timestamp.

It is the most common strategy for time-series data such as logs, events, and orders, because old data can be dropped or archived as a whole partition.

Declaring a Range-Partitioned Table

You declare partitioning with PARTITION BY RANGE on the parent table.

CREATE TABLE events (
    id bigserial,
    created_at timestamptz NOT NULL,
    payload jsonb
) PARTITION BY RANGE (created_at);

All lessons in this course

  1. Hash Partitioning for Distribution
  2. Sub-Partitioning Techniques
  3. Managing Partitioned Tables
  4. Range Partitioning by Time
← Back to Advanced PostgreSQL: Indexing, Partitioning, Replication