Search code examples
cassandrascylla

How do I change default compaction strategy in cassandra/scylla?


I've read that you can set compaction strategy per table in Cassandra/Scylla, as described here https://docs.scylladb.com/operating-scylla/procedures/config-change/change_compaction/

The default compaction strategy is Size-tiered compaction strategy (STCS).

But is there a way to change it somehow, in the settings, such that each table that's created uses another compaction strategy by default?

Thanks.


Solution

  • The compaction strategy is a sub-property of the compaction configuration of each table so you will need to use the CQL ALTER TABLE command to choose a different compaction strategy other than the default.

    In almost all cases, the SizeTieredCompationStrategy (STCS) is the right choice and so it is the default. There are very limited cases where you would choose a different compaction strategy.

    The most common situation where you would change it is if you have a time-series use case where TimeWindowCompactionStrategy (TWCS) is recommended. LeveledCompactionStrategy (LCS) is only valid for workloads were there is very little writes and your app is almost exclusively doing reads.

    So unless you fit into these narrow use cases, STCS should be your choice of compaction strategy. Cheers!