Table Partitioning
Split a table's data into smaller physical segments (partitions) based on column values for improved query performance and manageability.
table partitioning declarative partitioning range partitioning list partitioning hash partitioning
partitions performance storage create table range list hash
| Database | Status | Syntax Family | Min Version |
|---|---|---|---|
| PostgreSQL | full | declarative-partitioning | 10 |
| MySQL | full | inline-partition-definition | 5.1 |
| MariaDB | full | inline-partition-definition | 5.1 |
| Oracle | full | inline-partition-definition | 8i |
| SQL Server | full | partition-function-scheme | 2005 |
| SQLite | none | - | - |
| Redshift | partial | - | - |
| DB2 | full | inline-partition-definition | - |
| Snowflake | partial | - | - |
| BigQuery | full | inline-partition-definition | - |
Compare Databases
Database Details
PostgreSQL
full
CREATE TABLE events (
id BIGINT,
event_date DATE NOT NULL,
payload JSONB
) PARTITION BY RANGE (event_date);
CREATE TABLE events_2024 PARTITION OF events
FOR VALUES FROM ('2024-01-01') TO ('2025-01-01');- RANGE and LIST available in 10; HASH and DEFAULT partitions added in 11.
- Each partition is its own table, with independent indexes, constraints, and tablespace.
- Before 10, the same result was cobbled together with table inheritance plus trigger-based routing.
Docs: Table Partitioning
MySQL
full
CREATE TABLE events (
id BIGINT NOT NULL,
event_date DATE NOT NULL,
payload JSON
)
PARTITION BY RANGE (YEAR(event_date)) (
PARTITION p2023 VALUES LESS THAN (2024),
PARTITION p2024 VALUES LESS THAN (2025),
PARTITION pmax VALUES LESS THAN MAXVALUE
);- RANGE, LIST, HASH, KEY, plus composite subpartitioning.
- Partition expressions can call functions like YEAR() or TO_DAYS().
- Any unique index (including the primary key) must include the partition key columns.
- Fully supported on InnoDB and NDB; partial on other engines.
Docs: Partitioning
MariaDB
full
CREATE TABLE events (
id BIGINT NOT NULL,
event_date DATE NOT NULL,
payload LONGTEXT
)
PARTITION BY RANGE (YEAR(event_date)) (
PARTITION p2023 VALUES LESS THAN (2024),
PARTITION p2024 VALUES LESS THAN (2025),
PARTITION pmax VALUES LESS THAN MAXVALUE
);- Same inline-definition syntax as MySQL, with one MariaDB-only addition: PARTITION BY SYSTEM_TIME auto-manages history partitions for system-versioned tables.
Docs: Partitioning
Oracle
full
CREATE TABLE events (
id NUMBER,
event_date DATE NOT NULL,
payload CLOB
)
PARTITION BY RANGE (event_date) (
PARTITION p2023 VALUES LESS THAN (DATE '2024-01-01'),
PARTITION p2024 VALUES LESS THAN (DATE '2025-01-01'),
PARTITION pmax VALUES LESS THAN (MAXVALUE)
);- RANGE, LIST, HASH, INTERVAL (auto-creates range partitions on ingest), REFERENCE, plus composite forms.
- Requires the Oracle Partitioning option (Enterprise Edition license).
- Online partition maintenance: SPLIT, MERGE, MOVE, EXCHANGE.
Docs: Partitioning Concepts
SQL Server
full
CREATE PARTITION FUNCTION pf_event_date (DATE)
AS RANGE RIGHT FOR VALUES ('2024-01-01', '2025-01-01');
CREATE PARTITION SCHEME ps_event_date
AS PARTITION pf_event_date ALL TO ([PRIMARY]);
CREATE TABLE events (
id BIGINT,
event_date DATE NOT NULL,
payload NVARCHAR(MAX)
) ON ps_event_date(event_date);- Two-step setup: CREATE PARTITION FUNCTION, then CREATE PARTITION SCHEME, then CREATE TABLE ... ON the scheme.
- RANGE only. No native LIST or HASH as partition types.
- ALTER TABLE ... SWITCH moves entire partitions between tables without rewriting data.
- Enterprise Edition only (Developer counts for non-production).
SQLite
none
- No partitioning. For very large datasets, shard across tables or files manually and use ATTACH DATABASE.
Redshift
partial
- No partition DDL. The levers are DISTKEY (row distribution across slices, with DISTSTYLE EVEN / KEY / ALL) and SORTKEY (on-disk ordering).
- Zone maps on SORTKEY columns give range-scan pruning similar to partition pruning.
Docs: Working with sort keys
DB2
full
CREATE TABLE events (
id BIGINT,
event_date DATE NOT NULL,
payload CLOB
)
PARTITION BY RANGE (event_date) (
PARTITION p2023 STARTING '2023-01-01' ENDING '2023-12-31',
PARTITION p2024 STARTING '2024-01-01' ENDING '2024-12-31'
);- Inline RANGE partitioning with STARTING / ENDING bounds. Local (per-partition) and global indexes are both supported.
- Multi-dimensional clustering (MDC) is a separate physical-organization feature commonly combined with partitioning.
Docs: Partitioned tables
Snowflake
partial
- No PARTITION BY DDL. Snowflake auto-partitions into 50–500 MB micro-partitions; CLUSTER BY (col1, col2) hints how to group them for pruning.
- Automatic Clustering keeps the clustering up to date as data lands.
BigQuery
full
CREATE TABLE events (
id INT64,
created_at TIMESTAMP NOT NULL,
payload STRING
)
PARTITION BY DATE(created_at);- PARTITION BY DATE(col), PARTITION BY RANGE_BUCKET(col, GENERATE_ARRAY(...)), or ingestion-time partitioning.
- Partition expiry per partition is supported and is the common way to cap retention.
- Partitioning is the strongest cost-control lever, since it bounds scanned bytes per query.