Drupal is a registered trademark of Dries Buytaert

dboptimize

33 sites Security covered
View on drupal.org

DB Optimize

DbOptimize is a lightweight utility module that helps Drupal site administrators and developers keep their database tables optimized for better performance. It provides a simple UI and Cron integration to run SQL OPTIMIZE TABLE operations, along with a Drush command for quick CLI usage.

Key Features

  • ✅ Simple admin UI to configure and run database table optimizations.
  • ✅ Supports manual optimization through the admin interface.
  • ✅ Supports automatic optimization via Drupal Cron.
  • ✅ Supports CLI optimization via a Drush command.
  • ✅ Specify exactly which tables to optimize, or leave blank to optimize all tables.
  • ✅ Logs optimization actions in Drupal's system log (dblog).
  • ✅ Safe error handling with clear reporting.
  • ✅ Built following Drupal's coding standards and best practices.

Use Cases

  • Improve database performance on busy sites where tables like cache_*, watchdog, and sessions grow quickly.
  • Automate database maintenance on production and staging environments.
  • Perform quick table optimizations via Drush without accessing the database directly.
  • Keep your site's database healthy as part of regular maintenance workflows.

Installation & Usage

Install the module using Composer or place it in your contrib directory:

composer require drupal/dboptimize

Enable the module:

drush en dboptimize

Go to Configuration → System→ DB Optimize (/admin/config/system/dboptimize) to:

Add the tables you want to optimize (leave blank to optimize all).

Manually trigger the optimization.

View optimization results in the Recent Log Messages (/admin/reports/dblog).

Configure Cron to run optimizations automatically as needed.

Cron Integration

During Cron runs:

  • If table names are configured, only those tables will be optimized.
  • If no tables are configured, all database tables will be optimized.

Drush Command

Optimize your database directly from the CLI:

drush dboptimize:optimize
drush dboptimize:optimize --tables=cache_data,watchdog
drush dboptimize:analyze
drush dboptimize:analyze --tables=cache_data,watchdog
drush dboptimize:check
drush dboptimize:check --tables=cache_data,watchdog
drush dbo-repair
drush dbo-repair --tables=cache_data,watchdog

Compatibility

  • ✅ Fully compatible with Drupal 9 ,10 and 11.
  • ✅ Tested on MySQL and MariaDB.
  • ❌ PostgreSQL support is not implemented yet (pull requests welcome!).

Donation Support

This project took significant time to develop. If it has helped you save time in your work or business, feel free to contribute any amount you consider fair to support its continued development

Activity

Total releases
14
First release
Jul 2025
Latest release
4 months ago
Release cadence
8 days
Stability
93% stable

Release Timeline

Releases

Version Type Release date
1.2.1 Stable Oct 19, 2025
1.2.0 Stable Oct 18, 2025
1.1.1 Stable Oct 16, 2025
1.1.0 Stable Oct 16, 2025
1.0.9 Stable Oct 15, 2025
1.0.8 Stable Oct 14, 2025
1.0.7 Stable Sep 24, 2025
1.0.x-dev Dev Sep 24, 2025
1.0.6 Stable Sep 10, 2025
1.0.5 Stable Sep 10, 2025
1.0.3 Stable Aug 30, 2025
1.0.2 Stable Aug 29, 2025
1.0.1 Stable Jul 7, 2025
1.0.0 Stable Jul 7, 2025