How fast growing undo logs impact MySQL performance?

How fast growing undo logs impact MySQL performance?


Growing undo logs can impact MySQL performance in several ways:
  1. Increased disk space usage: As undo logs grow, they consume more disk space, which can lead to disk space issues, such as running out of disk space or slow disk I/O.
  2. Increased memory usage: The undo logs need to be kept in memory to ensure quick access during rollbacks, so as they grow, they consume more memory, which can lead to increased pressure on the buffer pool and cause the MySQL server to use more swap space.
  3. Increased contention: As undo logs grow, more undo logs are created and reused, which can lead to increased contention and lock waits, which can slow down the performance of the MySQL server.
  4. Increased checkpoint activity: As undo logs grow, more undo logs need to be checkpointed, which increases the workload of the background writer thread and can slow down the performance of the MySQL server.
  5. Increased rollback time: In the event of a rollback, the MySQL server needs to read the undo logs, so as they grow, the rollback process takes longer, which can slow down the performance of the MySQL server.
It's important to monitor undo logs and take appropriate action when they start to grow excessively. One of the ways to reduce undo logs is to increase the size of the innodb_undo_logs_size or innodb_undo_tablespaces system variable. Another way is to increase the size of the undo logs by increasing the undo_log_size system variable. This can help to reduce the number of undo logs that need to be created and reused. The Performance Schema in MySQL can be used to monitor the undo log. Here is a Python script that shows how to monitor the undo log using the Performance Schema: This script connects to the MySQL server, selects the data from the performance_schema.undo_log table and prints the results of undo_log_id, size, and creation time. You can also use the performance_schema.undo_log_stats table which shows the statistics of undo log usage, such as the total number of undo logs created and the total number of undo logs reused. It's important to keep in mind that the performance_schema must be enabled to access these tables. You can also schedule this script to run at regular intervals using a cron job or by using python scheduler library to monitor undo log usage over time.
About Shiv Iyer 72 Articles
Open Source Database Systems Engineer with a deep understanding of Optimizer Internals, Performance Engineering, Scalability and Data SRE. Shiv currently is the Founder, Investor, Board Member and CEO of multiple Database Systems Infrastructure Operations companies in the Transaction Processing Computing and ColumnStores ecosystem. He is also a frequent speaker in open source software conferences globally.

Be the first to comment

Leave a Reply