Black Friday - Cyber Monday Sale
30% OFF All Premium Licenses
  • 00 Days
  • 00 Hrs
  • 00 Mins
  • 00 Secs
Use code
SIGMA30

This 30% discount applies only to the first year. From the second year, renewals are charged at the regular price.

What are “tables to optimize” and how to clean them?

Younes JFR.

What are “tables to optimize”?

As your site runs, database tables accumulate overhead (fragmented free space) from inserts, updates, and deletes. “Tables to optimize” are tables with measurable overhead that can be reclaimed to reduce size and improve I/O efficiency. Optimizing them reorganizes storage and updates table statistics.

How they affect your database?

Overhead makes tables larger on disk and can slow some queries and backups. It’s normal to have some overhead, but large values – especially on busy sites – waste storage and may degrade performance over time.

How to clean them?

1. Using Advanced Database Cleaner plugin

Open the General Cleanup module in Advanced Database Cleaner plugin,
select “Tables to optimize” and run the cleanup. The plugin detects tables with overhead and executes safe optimization routines.

2. Using a raw SQL query

If you prefer a manual optimization, you can run the following SQL command in phpMyAdmin for example:

First, list tables with overhead, then run OPTIMIZE TABLE on chosen tables:

-- List tables and see Data_free (overhead)
SHOW TABLE STATUS;

-- Example: optimize specific tables
OPTIMIZE TABLE wp_posts, wp_postmeta, wp_comments;

Note:
While you can manually run these SQL commands to optimize your database tables, we strongly recommend using the Advanced Database Cleaner plugin.
It performs table optimization safely through WordPress’s internal methods, automatically handles multisite installations, and ensures that all tables are compacted and optimized without risking data corruption or index loss.