In order to reduce the storage overhead of binlog. TenDB implements a feature of binlog compression based on ZLIB algorithm. This feature can be turned on and off during operation, and can be applied to
How to use Binlog Compression
Turn on binlog compression:
set global log_bin_compress=ON
log_bin_compress_min_len specifies the compression threshold, only binlog field exceed this length will be compressed.
set global log_bin_compress_min_len=256
After testing, enabling binlog compression can achieve a compression ratio of 7 to 9. It is a good practice to reduce IO overhead at the cost of CPU.
There are two ways to decompress binlog for users to choose:
Decompress binlog in the IO thread:
set global relay_log_uncompress = ON
Decompress binlog in the SQL thread:
set global relay_log_uncompress = OFF
If the slave has enough relay-log space, you can set global relay_log_uncompress = ON (default configuration) to let binlog decompression done in the IO thread. If the slave has insufficient relay-log space, you can set global relay_log_uncompress = OFF and let binlog decompression done in the sql thread, but this may cause the slow sql thread down. However, slaves have parallel synchronization capabilities, so decompression in SQL threads generally does not have a significant impact on effiency.
Four new types of events are introduced.
QUERY_COMPRESSED_EVENT represents the DML event after compression in statement format;
DELETE_ROWS_COMPRESSED_EVENT respectively represent the insertion, update and delete events in row format after compression.
It is recommended to use TenDB's
mysqlbinlogtool for binlog operation.