Start compaction manually

You manually start compaction when automatic compaction fails for some reason. You can start compaction by running a Hive statement.

Carefully consider the need for a major compaction as this process can consume significant system resources and take a long time. Start a major compaction during periods of low traffic. Base and delta files for a table or partition are compacted.

Start compaction using a query

You use the following syntax to issue a query that starts compaction:
 ALTER TABLE tablename [PARTITION (partition_key='partition_value' [,...])] COMPACT 'compaction_type'
Files you are compacting must be in the ORC format.
  1. In Cloudera Manager, select the Hive metastore service: Clusters > Hive-1 > Configuration.
  2. Search for compact.
  3. Check that the Hive Metastore Server Default Group is selected (hive.compactor.initiator.on=true).
  4. Run a query to start a major compaction of a table.
    ALTER TABLE mytable COMPACT 'major'
    ALTER TABLE compacts tables even if the NO_AUTO_COMPACTION table property is set.