Recently I had the discussion with one of my colleague about the impact of MySQL binary logs . It was a nice discussion and triggered me further to benchmark the MySQL with/without binary logs . The result is amazing 🙂
Server configuration :
- 4 CPU
- 8 GB RAM
- 100 GB SSD
MySQL version : 8.0.19
I have conducted the test with a bulk transaction . It is a single thread INSERT with 9.5 GB of data .
Test 1 – With binary log :
screen 1 :
from the screen 1, I had split my terminal to three screens .
1st screen : I have triggered the bulk INSERT
2nd screen : The INSERT has started to execute and in executing state .
3rd screen : You can see the individual table-space file ( .ibd ) keep growing ( 5.6 GB ) on executing state .
screen 2 :
from the screen 2 ,
- When the executing state completed, the .ibd growth reached to 9.5 GB ( all the transaction data has been written into table-space )
- After executing state, the transaction data needs to be written into binary logs before commit .
- Mysqld/OS ( based on sync_binlog ) has started to write the events into binary log . That time the query state is “waiting for handler commit” in process list .
- Once all the events are written into binary logs, the query has completed .
Total Query Execution time with binary logs : 10 minutes 35 seconds
After this testing, I have truncated the table and restarted the MySQL with skip-log-bin .
Note : Before restart I have disabled the variables innodb_buffer_pool_dump_at_shutwon , innodb_buffer_pool_load_at_startup
Test 2 – Without binary log :
As per the experiment 1 ,
Here also the query took same time for executing the statement .
But, no huge time on the “waiting for handler commit” state , because we have disabled the binary logging . So it did not take long time to commit the transaction .
Total Query Execution time without binary logs : 6 minutes 27 seconds
- Binary logs will heavily affect the performance when the transaction size is huge
- Performance Impact is less in small transactions
- With STATEMENT based binary logging there is very very less performance impact ( but STATEMENT based logging is not good for production / replication )
- I have seen that, some peoples are using the HDD disk for binary logs and SSD disk for MySQL data directory. It will surely impact the performance when the transaction size is huge .
- Possibly, would suggest to make the setting binlog_row_image to MINIMAL . Still, it will not helps much during the heavy INSERT’s .
- Binary logs are important to PITR .