Overview
Database partitioning is the division of a large table into smaller, more manageable segments called partitions, each storing a subset of the data based on defined criteria. This approach provides significant performance advantages for inserts, queries, and deletions, and enables more efficient data management at scale.
In database tables, rows are partitioned according to the values of selected columns or transformations of the column values. For example, a partition based on the column month partitions the rows based on the month in a date value. Similarly, a partition based on bucket(X) partitions rows according to a hash of the column X — this tends to distribute rows evenly over the partitions.
Up to four columns can be specified as partition keys. Partitioning is defined at table creation. Once applied to a table, it cannot be removed or changed.
Query Performance
Queries benefit from partitioning in several ways:
Partition pruning — During table scans, the query engine skips partitions that are irrelevant to the query, dramatically reducing I/O.
Co-located joins and group-bys — Query engines can align execution splits to partition boundaries. In a group-by operation, each worker processes complete partitions without needing to shuffle data. In a join operation, if both tables share the same partitioning scheme and the join key matches the partition key, each worker joins its local partitions without cross-node data movement.
Insert and Delete Efficiency
Inserts benefit from partitioning by allowing data to be aggregated in memory per partition before being written in batches, reducing write amplification from background data reorganization. Deletes of entire partitions are significantly faster than row-level deletes.
Platform Support
Partitioning is supported for the following database clients:
Trino client
Spark client
The following features are compatible with partitioned tables:
Table sorting — Partitioning can be applied to tables that are sorted according to sorting columns, but partition columns with identity transforms cannot also be used for sorting.
Snapshots — Snapshots work correctly with partitioned tables.
Quota management — Quotas can apply to partitioned database tables.
Catalog — Displays partitioned tables (but not the partitions).
Tenant databases — Support partitioned tables in databases created by tenants or tenant users.
VAST on Cloud clusters — Support partitioned tables in cloud-based clusters.
Supported Column Transformations
Partitions are based on transformations of column values (including the identity transformation, which leaves the value unchanged).
The following transformations are supported:
Transformation name | Description | Source types | Result type |
|---|---|---|---|
identity | Source value, unmodified | Any | Source type |
bucket[N] | Hash of value, mod N | int, long, decimal, date, time, timestamp, timestamptz, timestamp_ns, timestamptz_ns, string, uuid, fixed-size binary, varbinary | int |
truncate[W] | Value truncated to width W | int, long, decimal, string, varbinary | Source type |
year | Extract a date or timestamp year, as years from 1970 | date, timestamp, timestamptz, timestamp_ns, timestamptz_ns | int |
month | Extract a date or timestamp month, as months from 1970-01-01 | date, timestamp, timestamptz, timestamp_ns, timestamptz_ns | int |
day | Extract a date or timestamp day, as days from 1970-01-01 | date, timestamp, timestamptz, timestamp_ns, timestamptz_ns | int |
hour | Extract a timestamp hour, as hours from 1970-01-01 00:00:00 | timestamp, timestamptz, timestamp_ns, timestamptz_ns | int |
Limitations
Values for columns used for partitioning cannot be changed after the row is inserted.
Columns used for partitioning cannot be updated or dropped after the table is created. An exception is a column update that leaves the rows in the partition unchanged.
Nested columns (such as lists or structs) cannot be used for partitioning.
Table partitioning cannot be used together with sorted projections or vector database indexing.
Partitioned tables cannot be replicated.
Creating Partitions
Creating a Partition Using the VAST Web UI
Partitions are defined for tables when the tables are created.
For details on table configuration options, see Creating a Table using the VAST Web UI.
Creating a Partition Using Trino
Use this syntax to add partitioning when creating a table using Trino:
CREATE TABLE table (
event_id int,
event_time timestamp(6),
event_type varchar
)
WITH (
partitioning = ARRAY['day(event_time)', 'event_type']
);In this example, the day transformation of the column event_time and the event_type column are used to create partitions. This creates a partition for each day and type combination.
Creating a Partition Using Spark or the VAST Query Engine
Use this syntax to add partitioning when creating a table using Spark or the VAST Query Engine:
CREATE TABLE table (
event_id int,
event_time timestamp(6),
event_type string
)
PARTITIONED BY (day(event_time), event_type)In this example, the day transformation of the column event_time and the event_type column are used to create partitions.
Deleting a Partition
You can delete partitions from an existing database table. This operation removes all rows matching the targeted partition boundaries.
Caution
This action is non-ACIDic. Modifying partition subsets while concurrent write procedures are targeted at the parent table can result in an indeterminate data execution state.
Deleting a Partition Using Trino
For a table created with partitions in Trino, such as:
CREATE TABLE table(col1 INTEGER, col2 INTEGER) WITH (partitioning = ARRAY['col1', 'bucket(col2, 1024)'])Use this syntax to delete the partitions:
DELETE FROM "table$partitions vast.allow_non_acid" WHERE col1 = 'value' and col2_bucket = 'transformed-value2'where table is the table partitioned by columns col1 and col2 (which uses the bucket transform function).
Note
The parameter flag
vast.allow_non_acidmust be appended to the targeted execution syntax statement.
Deleting a Partition Using Spark
For a table created with partitions in Spark, such as:
CREATE TABLE table(c1 BOOLEAN, c2 INTEGER, c3 INTEGER) PARTITIONED BY (bucket(8, c2), c1)Use this syntax to delete the partitions:
ALTER TABLE `table vast.allow_non_acid` DROP PARTITION (c2_bucket=4, c1=true)where table is the table partitioned by columns c1 and c2 (which uses the bucket transform function).
Note
The parameter flag
vast.allow_non_acidmust be appended to the targeted execution syntax statement.
Managing Partitions Using the VAST CLI
Creating a Partition Using the VAST CLI
To add partitioning parameters to a table execution configuration statement, use the table create command inside the command line interface and specify the --partitions-config parameter.