InnoDB/XtraDB Page Compression
MariaDB starting with 10.1.0
InnoDB/XtraDB Page Compression was added in MariaDB 10.1.0
Contents
Overview
Page compression is alternative way to compress you tables. In page compression, only uncompressed pages are stored on buffer pool. This approach differs significantly from legacy InnoDB compressed tables using row_format=compressed
, where both uncompressed and compressed pages can be in buffer pool. In page compression, page is actually compressed just before page is written to filespace. Similarly, page is uncompressed when it is read from tablespace before it is placed on buffer pool. Additionally, page compression supports different compression algorithms, not only zlib. For the moment, the only engines that fully support page compression are XtraDB and InnoDB.
Choosing compression algorithm
You specify which compression method to use with the
--innodb-compression-algorithm=
startup option for MariaDB. The options are:
Option | Description |
---|---|
none | Default. Data is not compressed. |
zlib | Pages are compressed with bundled zlib compression method. |
lz4 | Pages are compressed using <a href="https://code.google.com/p/lz4/">lz4 compression method</a> |
lzo | Pages are compressed using <a href="http://www.oberhumer.com/opensource/lzo/">lzo compression method</a> |
lzma | Pages are compressed using <a href="http://tukaani.org/xz/">lzma compression method</a> |
bzip2 | Pages are compressed using <a href="http://www.bzip.org/">bzip2 compression method</a> |
snappy | Pages are compressed using <a href="https://code.google.com/p/snappy/">snappy compression method</a> |
Because all of these compression methods are not available by default on all distributions, you may need to download desired compression method package from above links, install the package and finally recompile MariaDB server from source distribution with:
cmake . make make install
After the first command above, please check that cmake has found the desired compression method from your system.
Choosing compression level
You specify default compression level to use with the
--innodb-compression-level=
startup option for MariaDB values are 0-9.
Note that not all compression methods allow choosing compression level.
Creating compressed tables
Only tables that are specified to be compressed are actually compressed, you can create page compressed table with:
create table users(user_id int not null, b name varchar(200), primary key(user_id)) engine=innodb page_compressed=1;