Drupal performance and MySQL transaction isolation levels
When running Drupal on MySQL, the transaction isolation level can significantly affect site performance. By default, MySQL uses the REPEATABLE READ isolation level, but Drupal recommends READ COMMITTED to avoid deadlocks and improve efficiency. On ruachost.com, you may see a warning message in Drupal’s Status report if the isolation level is not set correctly.
Why Isolation Levels Matter
Section titled “Why Isolation Levels Matter”- REPEATABLE READ (default in MySQL) → Can cause deadlocks and slow performance in Drupal.
- READ COMMITTED (recommended) → Reduces deadlocks and improves concurrency.
- Correct configuration ensures smoother database operations and faster page loads.
Determining the Current Isolation Level
Section titled “Determining the Current Isolation Level”-
Log in to your server via SSH.
-
Access MySQL with:
Terminal window mysql -u username -p -
Run the command:
Terminal window SHOW variables WHERE variable_name LIKE "%isolation"; -
Check the output:
REPEATABLE-READ→ Default, may cause issues.READ-COMMITTED→ Recommended for Drupal.
Changing the Isolation Level
Section titled “Changing the Isolation Level”For Shared Hosting Accounts
Section titled “For Shared Hosting Accounts”-
Open the
settings.phpfile in your Drupal installation (sites/default/settings.php). -
Locate the database connection array.
-
Add or update the line:
'isolation_level' => 'READ COMMITTED', -
Save the file and refresh the Status report page in Drupal.
-
The warning message should disappear.
Important Notes
Section titled “Important Notes”- Always back up your database before making changes.
- Isolation level changes affect all databases on the server.
- Use
READ COMMITTEDfor optimal Drupal performance.