nodetool compact

Forces a major compaction on one or more tables.

Forces a major compaction on one or more tables.

Synopsis

nodetool <options> compact <keyspace>  <table> ... 
Table 1. Options
Short Long Description
-h --host Hostname or IP address
-p --port Port number
-pwf --password-file Password file path
-pw --password Password
-u --username User name
-- Separates an option from an argument that could be mistaken for a option.
Other options are:
  • keyspace is the name of a keyspace.
  • table is one or more table names, separated by a space.

Description

  • If you do not specify a keyspace or table, a major compaction is run on all keyspaces and tables.
  • If you specify only a keyspace, a major compaction is run on all tables in that keyspace.
  • If you specify one or more tables, a major compaction is run on those tables.

Major compactions may behave differently depending which compaction strategy is used for the affected tables:

  • Size-tiered compaction (STCS) splits repaired and unrepaired data into separate pools for separate compactions. A major compaction generates two SSTables, one for each pool of data.
  • Leveled compaction (LCS) performs size-tiered compaction on unrepaired data. After repair completes, Casandra moves data from the set of unrepaired SSTables to L0.
  • Date-tiered (DTCS) splits repaired and unrepaired data into separate pools for separate compactions. A major compaction generates two SSTables, one for each pool of data.

For more details, see The write path to compaction and Starting compaction.

Note: A major compaction can cause considerably more disk I/O than minor compactions.