COMPACT TABLE
Description
Manually triggers a compaction. Two granularities are available:
ADMIN COMPACT TABLE: triggers compaction for the tablets under the specified table partition.ADMIN COMPACT TABLET: triggers compaction for one specified tablet. Both commands have Cloud implementations in Core 26.1.3.
Syntax
ADMIN COMPACT TABLE <table_name>
PARTITION <partition_name>
WHERE TYPE={ BASE | CUMULATIVE | FULL }
ADMIN COMPACT TABLET <tablet_id>
WHERE TYPE={ BASE | CUMULATIVE | FULL }
Required parameters
ADMIN COMPACT TABLE
<table_name>
The name of the table for which compaction is to be triggered.
<partition_name>
The name of the partition for which compaction is to be triggered.
TYPE={ BASE | CUMULATIVE }
Where BASE refers to triggering a base compaction, and CUMULATIVE refers to triggering a cumulative compaction. For details, refer to the COMPACTION section.
ADMIN COMPACT TABLET
<tablet_id>
The ID of the tablet for which compaction is to be triggered. It must be a tablet of an internal (OLAP) table. Use
SHOW TABLETS FROM <table_name>to get it.
TYPE={ BASE | CUMULATIVE | FULL }
In addition to BASE and CUMULATIVE, FULL refers to triggering a full compaction.
Access control requirements
ADMIN COMPACT TABLE
The prerequisite for successfully executing this SQL command is to have ADMIN_PRIV permissions. Refer to the permission documentation.
| Privilege | Object | Notes |
|---|---|---|
| ADMIN_PRIV | Entire cluster management privileges | All privileges except NODE_PRIV |
ADMIN COMPACT TABLET
The prerequisite for successfully executing this SQL command is to have either the global ADMIN_PRIV privilege or the ALTER_PRIV privilege on the table the tablet belongs to. Either one is sufficient.
| Privilege | Object | Notes |
|---|---|---|
| ADMIN_PRIV | Entire cluster management privileges | All privileges except NODE_PRIV |
| ALTER_PRIV | Table | The ALTER privilege on the table the tablet belongs to is enough |
Example
- Trigger cumulative compaction for partition par01 of table tbl.
ADMIN COMPACT TABLE tbl PARTITION par01 WHERE TYPE='CUMULATIVE';
- Trigger full compaction for tablet 10086.
ADMIN COMPACT TABLET 10086 WHERE TYPE='FULL';
- Trigger base compaction for tablet 10086.
ADMIN COMPACT TABLET 10086 WHERE TYPE='BASE';
Usage notes
Commands submit background compaction work. A successful submission is not a completion or performance guarantee. Use an active cluster with the required SQL privileges. Manual compaction consumes compute and I/O. Confirm the need for manual intervention with VeloDB Cloud support.