MySQL & InnoDB (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
What is the Purge Thread and Undo Log Bloat in MySQL?
senior LevelDatabases & SQLMySQL
In Simple Words: When a transaction deletes a row, InnoDB does not delete it immediately from the B+ Tree; it marks it as deleted (Delete-Marked).
- Purge Thread: Background thread that physically removes delete-marked records and truncates undo logs once no active transactions need the historical read view.
- Long-Running Transactions Danger: If a developer leaves a transaction open for hours, the Purge Thread cannot delete undo logs. The undo log table space balloons to gigabytes, degrading overall database query performance!