nodetool compact

Forces a major compaction on one or more tables:

  • 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 only those tables.

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

A major compaction incurs considerably more disk I/O than minor compactions.

Synopsis

nodetool [options] compact [(-et <end_token> | --end-token <end_token>)]
[(-s | --split-output)] [(-st <start_token> | --start-token <start_token>)] [--] [<keyspace> [<tables>...]]
[--user-defined] <relative_path_to_SSTable file>...

Tarball and Installer No-Services path:

<installation_location>/resources/cassandra/bin

Common options

These options apply to all nodetool commands.

Common options
Short Long Description

-h

--host

Hostname or IP address.

-p

--port

Remote JMX agent port number.

-pw

--password

Password.

-pwf

--password-file

Password file path.

-u

--username

Remote JMX agent user name.

--

Separates an option from an argument that could be mistaken for an option.

  • For tarball installations, execute the command from the <installation_location>/bin directory.

  • If a username and password for RMI authentication are set explicitly in the cassandra-env.sh file for the host, then you must specify credentials.

    The location of the cassandra-env.sh file depends on the type of installation:

    • Package installations and installer-services installations: /etc/dse/cassandra/cassandra-env.sh

    • Tarball installations and installer-no services installations: INSTALLATION_LOCATION/resources/cassandra/conf/cassandra-env.sh

Compact options

The following options are specific to the compact command:

Compact options
Short Long Description

-et token

--end-token token

Specify a token at which the compaction range ends. Requires start token (-st).

-st token

--start-token token

Specify a token at which the compaction range starts. Requires end token (-et).

-s

--split-output

Instead of creating a single large file, split output when using SizeTieredCompactionStrategy (STCS) into files that are progressively smaller percentages of the total size, such as 50 percent, then 25 percent, then 12.5 percent.

  • For STCS, excluding the -s option creates a single large SSTable.

  • For DTCS (deprecated), using -s has no effect; a single file is still created.

  • nodetool compact -s only accepts keyspace table as an option. The command only works for the entire set of files in the table directory.

  • compact -s cannot be run on single sstable files; it can only be run on entire tables.

keyspace [tables]

Run compaction on an entire keyspace or specified tables; use a space to separate table names.

--user-defined sstable filenames

Run compaction on one or more SSTables. Specify the relative paths and file names.

Was this helpful?

Give Feedback

How can we improve the documentation?

© Copyright IBM Corporation 2026 | Privacy policy | Terms of use Manage Privacy Choices

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: Contact IBM