SQLMentor // glossary

Table Partitioning

Table partitioning splits one large logical table into smaller physical pieces (partitions) — commonly by date range, list of values, or hash — while queries still address it as a single table.

The main win is partition pruning: a query with a matching filter (WHERE order_date >= '2026-01-01') only scans the relevant partition instead of the whole table. Partitioning also makes bulk maintenance cheap — dropping an entire old partition to purge historical data is far faster than a row-by-row DELETE.

It's most valuable on very large, naturally-segmented tables — time-series data, logs, and multi-tenant data are classic candidates.

-- PostgreSQL range partitioning by month
CREATE TABLE orders (
  order_id INT, order_date DATE, total NUMERIC
) PARTITION BY RANGE (order_date);