Cut one big table into smaller pieces that are easier to manage.
Partitioning splits one big table into smaller pieces called partitions. To your queries it still looks like one table, but the database stores and reads it in parts.
As a table grows to hundreds of millions of rows, everything gets heavier: indexes are huge, scans take long, backups and vacuum jobs run for hours, and deleting old data blocks the table. Partitioning limits the size of each piece. Each partition is a smaller table with its own, smaller indexes.
There are two directions. Horizontal partitioning splits by rows (this month's orders in one piece, last month's in another). Vertical partitioning splits by columns (keep the small hot columns in one table and the big, rarely used ones, such as a long description or an image, in another). Most people mean horizontal when they say "partitioning".
| Method | How rows are placed | Good for | Watch out |
|---|---|---|---|
| Range | By a range of the key: dates, ids, numbers. | Time data, retention, range queries | The newest partition is hot. Uneven sizes. |
| Hash | hash(key) mod N chooses the partition. | Even spread, many equal lookups | Range queries read all partitions. Changing N moves lots of data. |
| List | A fixed list of values per partition (EU, US...). | Regions, categories, tenants | New values need a new partition. Sizes can be very uneven. |
| Composite (sub-partitioning) | Two levels, such as range by month then hash by customer. | Large tables that need both | More complex to design and run. |
| Vertical | Split columns into separate tables. | Hot columns vs big cold ones | Joins are needed to rebuild a row. |
CREATE TABLE orders (
id bigint,
customer_id bigint,
order_date date NOT NULL,
total numeric
) PARTITION BY RANGE (order_date);
CREATE TABLE orders_2026_03 PARTITION OF orders
FOR VALUES FROM ('2026-03-01') TO ('2026-04-01');
-- retention: remove a whole month quickly
ALTER TABLE orders DETACH PARTITION orders_2026_01;
DROP TABLE orders_2026_01;SELECT * FROM orders WHERE order_month = 'Nov'
A simplified model: 600 orders with fixed, made-up data (no random numbers), and each partition is scanned without an index. Real databases can also use indexes inside each partition, and the exact pruning rules depend on the database. Try this: a range split makes date queries cheap but sends all new writes to the latest partition; a hash split spreads writes but cannot prune date ranges.
| Term | Meaning in easy words |
|---|---|
| Partition | One piece of a table |
| Partition key | The column(s) that decide which partition a row goes to |
| Horizontal partitioning | Splitting a table by rows |
| Vertical partitioning | Splitting a table by columns |
| Partition pruning | Skipping partitions that cannot contain matching rows |
| Range / hash / list | The three main ways to assign rows to partitions |
| Skew | Uneven sizes or load between partitions |
| Hot partition | A partition that gets much more traffic than the others |
| Sub-partitioning | Partitioning each partition again with another rule |
| Detach / drop partition | Remove a whole partition in one fast step |
| Choice | We gain | We lose |
|---|---|---|
| Range by time | Great pruning and retention | Newest partition is the hot one |
| Hash by id | Even spread | No range pruning, hard to resize |
| List by region | Natural fit for local rules | Uneven sizes, new values need setup |
| Many small partitions | Fine-grained pruning | Planning cost and metadata overhead |
| Few large partitions | Less overhead | Less benefit, still heavy to maintain |