Compressing Events to Reduce Size of the Binary Log

Guide to using the `log_bin_compress` system variable to compress binary log events, reducing storage usage and network bandwidth during replication.

Selected events in the binary log can be optionally compressed, to save space in the binary log on disk and in network transfers.

Events that can be compressed are those that can be of significant size:

Compression is fully transparent. Events are compressed on the primary before being written to the binary log, and are uncompressed by the I/O thread on the replica before being written to the relay log. The mariadb-binlog command will likewise uncompress events for its output.

The zlib compression algorithm is used to compress events.

Compression has the greatest impact when events are of a non-negligible size, as each event is compressed individually – like batch INSERT statements that add many rows or large values, or row-based events that affect a number of rows in one query.

The log_bin_compress option is used to enable compression of events. Only events with data (query text or row data) above a certain size are compressed; the limit is set with the log_bin_compress_min_len option.

This page is licensed: CC BY-SA / Gnu FDL

spinner

Last updated

Was this helpful?