Was this page helpful?
Caution
You're viewing documentation for an unstable version of ScyllaDB Manual. Switch to the latest stable version.
Compression Advisor¶
The Compression Advisor (tools/compression_advisor.py) analyzes the
compression configuration of a single table and recommends whether a different
compressor, compression level, or chunk length would meaningfully reduce its
on-disk size.
It reads the table’s current compression settings over CQL, asks the node to
estimate compression ratios for a range of candidate configurations through the
estimate_compression_ratios REST API, and prints a color-coded heatmap grid,
a summary table comparing the current configuration against the best LZ4 and
ZSTD candidates, and a single ready-to-run ALTER TABLE statement for the
best overall recommendation.
The advisor only recommends a change when it improves the estimated compression ratio by at least 5%, and it prefers the default 4 KB chunk length unless a larger chunk is more than 5% better. This avoids churning table settings for negligible gains.
Prerequisites¶
Python 3.
The ScyllaDB Python driver (
scylla-driver), used to read the current compression configuration over CQL. Install it with:pip install scylla-driverWithout the driver, the tool still runs and prints the heatmap and recommendations, but cannot compare against the current configuration.
Network access from where you run the tool to:
the ScyllaDB CQL native transport port (
9042by default), andthe ScyllaDB Admin REST API port (
10000by default).
The
SSTABLE_COMPRESSION_DICTScluster feature must be enabled on all nodes. If not enabled, theestimate_compression_ratiosREST API is unavailable and Compression Advisor reports that the API returned invalid JSON.
Usage¶
python3 tools/compression_advisor.py --host <node-ip> --keyspace <ks> --table <tbl> [options]
For example:
python3 tools/compression_advisor.py --host 127.0.0.1 --keyspace myks --table mytbl
To disable the ANSI color output (for example when redirecting to a file):
python3 tools/compression_advisor.py --host 127.0.0.1 --keyspace myks --table mytbl --no-color
If the cluster uses PasswordAuthenticator, pass CQL credentials so the tool
can read the current compression configuration:
python3 tools/compression_advisor.py --host 127.0.0.1 --keyspace myks --table mytbl --username scylla --password mypassword
Options¶
Option |
Default |
Description |
|---|---|---|
|
(required) |
IP address of a ScyllaDB node to query. |
|
(required) |
Keyspace name of the table to analyze. |
|
(required) |
Table name to analyze. |
|
|
ScyllaDB Admin REST API port. |
|
|
ScyllaDB CQL native transport port. |
|
(none) |
CQL username, required if the cluster uses |
|
(none) |
CQL password, required if the cluster uses |
|
off |
Disable ANSI color output. Color is also disabled automatically when the output is not a terminal. |
Run the tool with -h / --help for the full list of options.
Output¶
The advisor prints three sections:
Heatmap grid — the estimated compression ratio for every candidate compressor / chunk length / level combination, color-coded so the most effective configurations stand out. The current configuration is highlighted.
Summary table — the current configuration alongside the best LZ4 and best ZSTD candidates, with the estimated size reduction relative to the current setting.
Recommended change — a single
ALTER TABLEstatement for the best overall recommendation (chosen between the best LZ4 and best ZSTD candidate). When a dictionary-aware compressor with a retrained dictionary is recommended, the tool also prints the correspondingretrain_dictREST call needed to train the compression dictionary.
The recommended ALTER TABLE statement always quotes the keyspace and table
identifiers, uses the dictionary-capable compressor names returned by the
estimator (for example ZstdWithDictsCompressor), and includes
compression_level for ZSTD. For example:
ALTER TABLE "myks"."mytbl" WITH compression = {'sstable_compression': 'ZstdWithDictsCompressor', 'chunk_length_in_kb': '4', 'compression_level': '5'};
If the recommendation uses a retrained dictionary, the tool also prints, as comments, the REST call to train it:
-- Then retrain the dictionary (requires SSTABLE_COMPRESSION_DICTS feature):
-- POST /storage_service/retrain_dict?keyspace=myks&cf=mytbl
When no change improves the estimated ratio by more than 5%, the tool reports
that the current configuration is already optimal instead of printing an
ALTER TABLE statement.
Note
The advisor only estimates and recommends; it never modifies the table.
Apply any recommended ALTER TABLE statement yourself after reviewing it.