Partitioning: splitting a big table so most queries only touch a slice of it
Partitioning doesn't shrink a table. It splits it into pieces so a well-aimed query only has to open the piece it needs.
Partitioning splits one very large table into smaller physical pieces, while keeping a single name for querying, so most queries only have to touch the piece they actually need.
🎯 Explain Like I'm Hired Partitioning is like splitting one giant filing cabinet into twelve smaller ones, one per month, but keeping a single label on the outside, so it still looks like one cabinet to anyone searching it. Ask for "January's files" and the system only opens the January drawer, not all twelve. Example: a query filtered to a specific month, against a table partitioned by month, only scans that one month's slice ("partition pruning") instead of years of data.
CREATE TABLE orders (
id uuid, customer_id uuid, amount numeric, placed_at date
) PARTITION BY RANGE (placed_at);
CREATE TABLE orders_2025_01 PARTITION OF orders
FOR VALUES FROM ('2025-01-01') TO ('2025-02-01');
Sign up to keep reading
Sign up free to unlock the worked examples, edge cases, and interview traps below.