Compressing events to reduce size of the binary log

Starting from MariaDB 10.2.3, selected events in the binary log can be optionally compressed, to save space in the binary log on disk and in network transfers.

The events that can be compressed are the events that normally can be of a significant size: Query events (for DDL and DML in statement-based replication), and row events (for DML in row-based replication).

Compression is fully transparent. Events are compressed on the master before being written into the binary log, and are uncompressed by the I/O thread on the slave before being written into the relay log. The mysqlbinlog command will likewise uncompress events for its output.

Currently, the zlib compression algorithm is used to compress events.

Compression will have the most impact when events are of a non-negligible size, as each event is compressed individually. Examples would include eg. batch INSERT statements that inserts many rows or large values; or row-based events that touch a number of rows in one query.

The option log_bin_compress 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 option log_bin_compress_min_len.

log_bin_compress

  • Description: Whether the binary log can be compressed
  • Commandline: --log-bin-compress
  • Scope: Global
  • Dynamic: Yes
  • Data Type: boolean
  • Default Value: OFF (0)
  • Introduced: MariaDB 10.2.3

log_bin_compress_min_len

  • Description: Minimum length of sql statement(in statement mode) or record(in row mode) that can be compressed.
  • Commandline: --log-bin-compress-min-len
  • Scope: Global
  • Dynamic: Yes
  • Data Type: numeric
  • Default Value: 256
  • Range: 10 to 1024
  • Introduced: MariaDB 10.2.3

Comments

Comments loading...