Starting compaction manually
You manually start compaction when automatic compaction fails for some reason. You can start compaction by running a Hive statement.
AND WAITclause. Compaction actually occurs asynchronously, but seems synchronous. The compaction request is recorded and queued, and remains in a waiting cycle, querying the status of the compaction in the background until a failure, success, or timeout occurs. The
hive.compactor.wait.timeout(default: 300s) property sets the timeout.
Start compaction using a queryYou use the following syntax to issue a query that starts compaction:
ALTER TABLE tablename [PARTITION (partition_key='partition_value' [,...])] COMPACT 'compaction_type'
Required role: DWAdmin
- Tables or partitions you are compacting must be full ACID or insert-only ACID tables.
- Compaction must be enabled (
Run a query to start a major compaction of a table.
ALTER TABLE mytable COMPACT 'major'Use the
COMPACT 'minor'clause to run a minor compaction.
ALTER TABLEcompacts tables even if the
NO_AUTO_COMPACTIONtable property is set.
Start compaction in a pseudo-synchronous way.
ALTER TABLE mydb.mytable PARTITION (mypart='myval') COMPACT 'MAJOR' AND WAIT;