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
- Hash Partitioning for Distribution
- Sub-Partitioning Techniques
- Managing Partitioned Tables
- Range Partitioning by Time