ALTER TABLE SQUASH PARTITIONS
Merges split folders into one partition and folds merge-append partitions back into the standard layout, reclaiming dead space even in partitions without splits. Before downgrading, follow the safe downgrade procedure. For non-WAL conversion, follow the merge-append disable procedure to prevent new merge-append writes.
Syntax
ALTER TABLE tableName SQUASH PARTITIONS;
Examples
Use SHOW PARTITIONS to inspect the splits
in table x. Both results below show selected columns.
SHOW PARTITIONS FROM x;
| index | partitionBy | name | minTimestamp | maxTimestamp | numRows | diskSize | diskSizeHuman | readOnly | active |
|---|---|---|---|---|---|---|---|---|---|
| 0 | DAY | 2023-02-04 | 2023-02-04T00:00:00.000000Z | 2023-02-04T23:59:59.940000Z | 1440000 | 71281136 | 68.0 MiB | FALSE | FALSE |
| 1 | DAY | 2023-02-05 | 2023-02-05T00:00:00.000000Z | 2023-02-05T20:59:59.880000Z | 1259999 | 65388544 | 62.4 MiB | FALSE | FALSE |
| 2 | DAY | 2023-02-05T205959-880001 | 2023-02-05T20:59:59.940000Z | 2023-02-05T21:59:59.940000Z | 60002 | 83886080 | 80.0 MiB | FALSE | TRUE |
The two rows for 2023-02-05 are splits of the same daily partition.
To merge the two partitions:
ALTER TABLE x SQUASH PARTITIONS;
SHOW PARTITIONS FROM x;
| index | partitionBy | name | minTimestamp | maxTimestamp | numRows | diskSize | diskSizeHuman | readOnly | active |
|---|---|---|---|---|---|---|---|---|---|
| 0 | DAY | 2023-02-04 | 2023-02-04T00:00:00.000000Z | 2023-02-04T23:59:59.940000Z | 1440000 | 71281136 | 68.0 MiB | FALSE | FALSE |
| 1 | DAY | 2023-02-05 | 2023-02-05T00:00:00.000000Z | 2023-02-05T21:59:59.940000Z | 1320001 | 65388544 | 62.4 MiB | FALSE | TRUE |