Description:
COMPRESSION_PERCENTAGE in binary_log_transaction_compression_stats is incorrect when the compression rate is very high.
How to repeat:
1. execute the following sql:
mysql> select COMPRESSION_TYPE,TRANSACTION_COUNTER,COMPRESSED_BYTES_COUNTER,UNCOMPRESSED_BYTES_COUNTER,COMPRESSION_PERCENTAGE from performance_schema.binary_log_transaction_compression_stats;
+------------------+---------------------+--------------------------+----------------------------+------------------------+
| COMPRESSION_TYPE | TRANSACTION_COUNTER | COMPRESSED_BYTES_COUNTER | UNCOMPRESSED_BYTES_COUNTER | COMPRESSION_PERCENTAGE |
+------------------+---------------------+--------------------------+----------------------------+------------------------+
| ZSTD | 6032130 | 1494533417 | 1165338872550 | 100 |
| NONE | 90144 | 28623075567 | 28623075567 | 0 |
+------------------+---------------------+--------------------------+----------------------------+------------------------+
2 rows in set (0.00 sec)
2. The COMPRESSION_PERCENTAGE is 100, but UNCOMPRESSED_BYTES_COUNTER/COMPRESSED_BYTES_COUNTER = 779.
COMPRESSION_PERCENTAGE does not reflect the true compression rate.
Suggested fix:
I expect to change COMPRESSION_PERCENTAGE to UNCOMPRESSED_BYTES_COUNTER/COMPRESSED_BYTES_COUNTER not (1 - COMPRESSED_BYTES_COUNTER/UNCOMPRESSED_BYTES_COUNTER) * 100 .