Storage-engine independent column compression enables TINYBLOB, BLOB, MEDIUMBLOB, LONGBLOB, TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT, VARCHAR and VARBINARY columns to be compressed.
This is performed by means of a new COMPRESSED column attribute:COMPRESSED[=<compression_method>]
Currently the only supported compression method is zlib.
When using the COMPRESSED attribute, note that FIELD LENGTH is reduced by 1; for example, a BLOB has a length of 65535, while BLOB COMPRESSED has 65535-1. See .
column_compression_thresholdDescription: Minimum column data length eligible for compression.
Command line: --column-compression-threshold=#
Scope: Global, Session
Dynamic: Yes
column_compression_zlib_levelDescription: zlib compression level (1 gives best speed, 9 gives best compression).
Command line: --column-compression-zlib-level=#
Scope: Global, Session
Dynamic: Yes
column_compression_zlib_strategyDescription: The strategy parameter is used to tune the compression algorithm. Use the value DEFAULT_STRATEGY for normal data, FILTERED for data produced by a filter (or predictor), HUFFMAN_ONLY to force Huffman encoding only (no string match), or RLE to limit match distances to one (run-length encoding). Filtered data consists mostly of small values with a somewhat random distribution. In this case, the compression algorithm is tuned to compress them better. The effect of FILTERED is to force more Huffman coding and less string matching; it is somewhat intermediate between DEFAULT_STRATEGY and HUFFMAN_ONLY. RLE is designed to be almost as fast as HUFFMAN_ONLY
column_compression_zlib_wrapDescription: If set to 1 (0 is default), generate zlib header and trailer and compute adler32 check value. It can be used with storage engines that don't provide data integrity verification to detect data corruption.
Command line: --column-compression-zlib-wrap{=0|1}
Scope: Global, Session
Column_compressionsDescription: Incremented each time field data is compressed.
Scope: Global, Session
Data Type: numeric
Column_decompressionsDescription: Incremented each time field data is decompressed.
Scope: Global, Session
Data Type: numeric
The only supported method currently is zlib.
The storage engine stores data uncompressed on-disk even if the COMPRESSED attribute is present.
It is not possible to create indexes over compressed columns.
Storage-independent column compression is different to in a number of ways.
It is storage engine independent, while InnoDB page compression applies to InnoDB only.
By being specific to a column, one can access non-compressed fields without the decompression overhead.
Only zlib is available, while InnoDB page compression can offer alternative compression algorithms.
It is not recommended to use multiple forms of compression over the same data.
This page is licensed: CC BY-SA / Gnu FDL
Data Type: numeric
Default Value: 100
Range: 0 to 4294967295
Data Type: numeric
Default Value: 6
Range: 1 to 9
FIXEDCommand line: --column-compression-zlib-strategy=#
Scope: Global, Session
Dynamic: Yes
Data Type: enum
Default Value: DEFAULT_STRATEGY
Valid Values: DEFAULT_STRATEGY, FILTERED, HUFFMAN_ONLY, RLE, FIXED
Dynamic: Yes
Data Type: boolean
Default Value: OFF
It is intended for compressing large blobs, while InnoDB page compression is suitable for a more general case.
Columns cannot be indexed, while with InnoDB page compression indexes are possible as usual.
CREATE TABLE cmp (i TEXT COMPRESSED);
CREATE TABLE cmp2 (i TEXT COMPRESSED=zlib);Optimize MariaDB Server performance and storage with compression. This section details how to apply data compression at various levels to reduce disk space and improve I/O efficiency.
MariaDB starting with
Compressions plugins were added in a preview release.
The various MariaDB storage engines, such as InnoDB, RocksDB, Mroonga, can use different compression libraries.
Before , each separate library would have to be compiled in order to be available for use, resulting in numerous runtime/rpm/deb dependencies, most of which would never be used by users.
From , five additional MariaDB compression libraries (besides the default zlib) are available as plugins (note that these affect InnoDB and Mroonga only; RocksDB still uses the compression algorithms from its own library):
bzip2
lzma
lz4
lzo
snappy
Depending on how MariaDB was installed, the libraries may already be available for installation, or may first need to be installed as .deb or .rpm packages, for example:
Once available, , for example:
The compression algorithm can then be used, for example, in :
When upgrading from a release without compression plugins, if a non-zlib compression algorithm was used, those tables will be unreadable until the appropriate compression library is installed. should be run. The --force option (to run ) or mariadb-check itself will indicate any problems with compression, for example:
or
In this case, the appropriate compression plugin should be installed, and the server restarted.
(mariadb.org blog)
Add zstd as a compression plugin -
This page is licensed: CC BY-SA / Gnu FDL
apt-get install mariadb-plugin-provider-lz4INSTALL SONAME 'provider_lz4';SET GLOBAL innodb_compression_algorithm = lz4;Warning : MariaDB tried to use the LZMA compression, but its provider plugin is not loaded
Error : Table 'test.t' doesn't exist in engine
status : Operation failedError : Table test/t is compressed with lzma, which is not currently loaded.
Please load the lzma provider plugin to open the table
error : Corrupt