Partitioned Table Architecture
Table partitioning is a database technique that divides a large logical table into smaller physical sub-tables called partitions, each storing a subset of the rows, while the database engine presents them to queries as a single table.
Table partitioning is a database technique that divides a large logical table into smaller physical sub-tables called partitions, each storing a subset of the rows, while the database engine presents them to queries as a single table.
This diagram shows how a partitioned table is structured and how queries route to the correct partitions. The parent table (also called the partitioned table) holds no data itself; it is a logical container that defines the partitioning key and strategy. Queries against the parent table are transparently routed by the partition pruning logic in the query planner.
There are three common partitioning strategies. Range partitioning assigns rows to partitions based on a value range — for example, a logs table partitioned by month, so January data lives in logs_2024_01, February in logs_2024_02, and so on. This is the most common strategy for time-series data. List partitioning assigns rows based on an explicit list of values — for example, a orders table partitioned by region with one partition per geographic region. Hash partitioning distributes rows evenly by hashing the partition key, similar in concept to Database Sharding but within a single database instance.
Partition pruning is the key performance benefit: a query with WHERE created_at BETWEEN '2024-01-01' AND '2024-01-31' only scans the January partition, skipping all others. Each partition can have its own indexes, tablespace, and even different storage parameters. Old partitions can be dropped instantly (a single metadata operation) rather than with slow DELETE statements.
The main operational cost is that queries without a partition key in the WHERE clause must scan every partition — a full partition scan that can be worse than a single unpartitioned table scan. Designing the partitioning key around your most common query predicates is critical.