# Optimise your WordPress database
Source: https://docs.webgee.com/en/hosting/wordpress/how-to-optimize-your-wordpress-database



WordPress databases accumulate data that is never read again — old post
revisions, abandoned drafts, expired transients, deleted comments. Clearing it
reduces database size and speeds up queries. Applies to all shared and reseller
hosting, which runs LiteSpeed.

The **Database Optimizer** is part of the LiteSpeed Cache plugin, so if the
plugin is installed you already have it. See
[Install and enable LiteSpeed Cache](/en/hosting/wordpress/how-do-i-install-and-enable-litespeed-cache).

<Callout type="warn">
  Take a backup first. Every option here deletes data permanently, and there is
  no undo. See
  [Download a backup of your account](/en/backups/how-to-generate-download-a-website-backup).
</Callout>

## Open it [#open-it]

In the WordPress dashboard, go to **LiteSpeed Cache** → **Manage**, then the
**DB Optimizer** tab.

Blue check marks mean an area is already clean. Red crosses mean there is
something to remove.

## What each option removes [#what-each-option-removes]

| Option                     | Removes                                             | Safe to run                          |
| -------------------------- | --------------------------------------------------- | ------------------------------------ |
| **Post Revisions**         | Every saved revision, leaving the published version | Yes, if you do not need edit history |
| **Auto Drafts**            | Automatic drafts WordPress saves while editing      | Yes                                  |
| **Trashed Posts**          | Posts and pages in the Trash                        | Yes, once you have checked the Trash |
| **Trashed Comments**       | Comments in the Trash                               | Yes                                  |
| **Spam Comments**          | Comments marked as spam                             | Yes                                  |
| **Trackbacks & Pingbacks** | Trackback and pingback records                      | Yes                                  |
| **Expired Transients**     | Cached values whose lifetime has passed             | Yes                                  |
| **All Transients**         | Every transient, expired or not                     | Yes, but see below                   |
| **Optimize Tables**        | Nothing — reclaims space inside the tables          | Yes                                  |
| **Clean CSS/JS Optimizer** | Minified and combined CSS/JS data                   | Yes                                  |

**Clean All** runs everything except **Optimize Tables** and **Clean CSS/JS
Optimizer**. Run those two separately.

## The two worth thinking about [#the-two-worth-thinking-about]

**Post Revisions** is usually the largest single saving. WordPress keeps every
revision of every post forever, so a heavily edited site can hold ten times more
revision rows than published content. The cost is that you lose the ability to
roll a post back to an earlier draft.

To keep some history rather than none, cap revisions in `wp-config.php` instead
of deleting them repeatedly:

```php
define( 'WP_POST_REVISIONS', 5 );
```

**All Transients** deletes cached values that have not yet expired. Nothing
breaks — WordPress regenerates them on demand — but the next few page loads are
slower while it does, and some plugins store licence checks and API responses as
transients. Prefer **Expired Transients** for routine cleaning.

## Do this periodically, not constantly [#do-this-periodically-not-constantly]

Once a month is ample for most sites. Running it daily produces no measurable
benefit and repeatedly rewrites the tables.

If the database is still large after cleaning, the size is in real content or in
plugin tables the optimiser does not touch — commonly logging, analytics or
form-submission plugins storing rows indefinitely. Check those plugins' own
retention settings.

## Verify [#verify]

* The DB Optimizer tab shows blue check marks where it showed red crosses.
* The site loads normally, including a logged-out page and the dashboard.
* Database size in cPanel has dropped, after running **Optimize Tables** — until
  then the rows are deleted but the space is not reclaimed.

## Related [#related]

* [Install and enable LiteSpeed Cache](/en/hosting/wordpress/how-do-i-install-and-enable-litespeed-cache)
* [Improve a slow WordPress or WooCommerce dashboard](/en/hosting/wordpress/how-to-improve-a-slow-wordpress-or-woocommerce-dashboard)
