Compression subproperties

Configuring compression for a table.

Using CQL, you can configure compression for a table by constructing a map of the compaction property and the following subproperties:

Table 1. CQL Compression Subproperties
Compression Subproperties Default Description
sstable_compression SnappyCompressor The compression algorithm to use. Valid values are LZ4Compressor, SnappyCompressor, and DeflateCompressor. See sstable_compressionbelow.
chunk_length_kb 64KB On disk, SSTables are compressed by block to allow random reads. This subproperty of compression defines the size (in KB) of the block. Values larger than the default value might improve the compression rate, but increases the minimum size of data to be read from disk when a read occurs. The default value is a good middle-ground for compressing tables. Adjust compression size to account for read/write access patterns (how much data is typically requested at once) and the average size of rows in the table.
crc_check_chance 1.0 When compression is enabled, each compressed block includes a checksum of that block for the purpose of detecting disk bitrot and avoiding the propagation of corruption to other replica. This option defines the probability with which those checksums are checked during read. By default they are always checked. Set to 0 to disable checksum checking and to 0.5, for instance, to check them on every other read.


The compression algorithm to use. Valid values are LZ4Compressor SnappyCompressor, and DeflateCompressor. Use an empty string ('') to disable compression:
ALTER TABLE mytable WITH COMPRESSION = {'sstable_compression': ''};
Choosing the right compressor depends on your requirements for space savings over read performance. LZ4 is fastest to decompress, followed by Snappy, then by Deflate. Compression effectiveness is inversely correlated with decompression speed. The extra compression from Deflate or Snappy is not enough to make up for the decreased performance for general-purpose workloads, but for archival data they may be worth considering. Developers can also implement custom compression classes using the interface. Specify the full class name as a "string constant".