COMPACT
COMPACT improves a table’s physical file layout by merging small Parquet
files and re-sorting files with overlapping sort-key ranges.
Example
Section titled “Example”Run a compaction round on an existing table:
COMPACT events;Syntax
Section titled “Syntax”COMPACT [datastore.][schema.]table [FINAL];Compaction behavior
Section titled “Compaction behavior”Regular COMPACT merges small files and re-sorts overlapping files until no
further merges qualify under the normal compaction rules. These rules use
file sizes, file counts, and the amount of overlap to decide when to merge.
The datastore’s compaction settings control output targets and concurrency.
COMPACT events FINAL;FINAL runs a more aggressive compaction. It relaxes the normal merge
thresholds, merging remaining small files and re-sorting eligible files until
no two have overlapping sort-key ranges within a partition.
Related
Section titled “Related”- Datastore maintenance - background compaction and its settings.
- CREATE TABLE sorting - choose sort columns.
- System tables - inspect file and table metadata.
