InnoDB/XtraDB Page Compression

You are viewing an old version of this article. View the current version here.
MariaDB starting with 10.1.0

InnoDB/XtraDB Page Compression was added in MariaDB 10.1.0

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:

OptionDescription
noneDefault. Data is not compressed.
zlibPages are compressed with bundled zlib compression method.
lz4Pages are compressed using <a href="https://code.google.com/p/lz4/">lz4 compression method</a>
lzoPages are compressed using <a href="http://www.oberhumer.com/opensource/lzo/">lzo compression method</a>
lzmaPages are compressed using <a href="http://tukaani.org/xz/">lzma compression method</a>
bzip2Pages are compressed using <a href="http://www.bzip.org/">bzip2 compression method</a>
snappyPages 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;

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.