GoDaddy Help

Clean and prevent database bloat on my WordPress site

A bloated WordPress database is primarily caused by accumulating unnecessary data, such as old post revisions, spam comments, unused plugin data, outdated theme settings, and large amounts of overhead. This data builds up over time with every action taken on the site, leading to a larger database size and potential performance issues. You can clean up the database and mitigate further bloating with built-in tools, third-party plugins, and, in extreme cases, within the database directly.

Warning: You should always back up your site before making changes to the database.

These are the most common causes of database bloat.

Excessive post revisions

Cleaning up excessive post revisions in WordPress helps optimize your site's performance by reducing database bloat. This leads to faster loading times and a more efficient website. Each revision takes up space in the database and can slow down your site if left unchecked.

Limit or disable post revisions with a plugin

To limit post revisions in WordPress, you can install a plugin to manage the settings. There are several plugin options. We suggest a lightweight plugin like WP Revisions Control.

  1. Install the plugin and activate it.
  2. On the left-side menu, select Settings and then Writing.
  3. In the WP Revisions Control section, enter the number of revisions you want to retain for Post and Pages. Leaving these fields blank will retain all revisions. Limiting your site to 3 or 5 revisions for Posts and Pages is usually more than enough.
  4. (Optional) To disable revisions for Posts and Pages, fill the field with 0.
  5. Select Save Changes.

Limit or disable post revisions by editing the wp-config.php file

To limit post revisions in WordPress, you can add a line of code in your wp-config.php file, using the define('WP_POST_REVISIONS', number); command, where "number" represents the desired maximum number of revisions you want to keep per post; for example, define('WP_POST_REVISIONS', 3); would limit each post to 3 revisions.

  1. Connect to your hosting with FTP or File Manager.
  2. In the folder with your WordPress installation, find the wp-config.php file.
  3. Open the wp-config.php file and find the following line:
    /* That's all, stop editing! Happy publishing. */
  4. Just above this line, add the following code:
    define('WP_POST_REVISIONS', 3)
    Note: You can disable post revisions using 0 or false; for example, define('WP_POST_REVISIONS,' 0); it would not store any revisions (except the one autosave per post).
  5. Save your changes.

Clean up post revisions

You can bulk delete all post revisions directly in the database with an SQL query by following these steps.

  1. Access your database through phpMyAdmin.
  2. Navigate to the SQL tab and execute the following query:
    DELETE FROM wp_posts WHERE post_type = ‘revision’;
    Note: wp_ is the default database table prefix. If your table prefix isn't wp_, find your table prefix and use that in your query. Example: wp_xufdzp_posts.
  3. Select Go.

Back to top

Spam comments

Preventing spam comments on your WordPress site can improve your website's reputation by keeping your comment section clean, improving user experience, potentially boosting SEO, and protecting your site from malicious activity by filtering out automated bot comments that could harm your website's security and credibility; essentially, it creates a more positive and trustworthy environment for genuine visitors and interactions.

Here are some resources for managing comment settings and removing spam comments.

Back to top

Unused plugins and themes

Removing unused plugins and themes from a WordPress site can help improve its performance by reducing the amount of data that needs to be processed, enhancing security by minimizing potential vulnerabilities from outdated code, simplifying site management by decluttering the dashboard, and potentially decreasing the size of backups you need to store.

Back to top

Excessive overhead

Removing excess overhead from a WordPress site is crucial for improving your site's performance by reducing the amount of unnecessary data stored in the database, which can lead to faster loading times and better overall site efficiency, especially when dealing with large amounts of old, unused metadata accumulated over time. Additionally, keeping metadata up-to-date can contribute to better SEO by ensuring search engines have accurate information about your content.

Here's how you can optimize your MySQL database to clear the overhead.

Back to top

Pingbacks and trackbacks

Most WordPress users remove pingbacks and trackbacks from their sites primarily to combat spam. Automated bots often exploit these features to insert irrelevant links into the comment section, requiring significant moderation effort and cluttering the site with low-quality content. Additionally, disabling them can improve site performance by reducing unnecessary server requests and enhance security by mitigating potential DDoS attack vectors.

Disable pingbacks and trackbacks

  1. Sign in to WordPress.
  2. From the left-side menu, select Settings, and then Discussion.
  3. Under Default post settings, clear the checkbox for Allow link notifications from other blogs (pingbacks and trackbacks) on new posts.
  4. Select Save Changes.

Delete pingbacks and trackbacks in the WordPress Dashboard

  1. Sign in to WordPress.
  2. From the left-side menu, select Comments.
  3. Filter for "Pings": In the dropdown menu select Pings and then select Filter to view only pingbacks and trackbacks.
  4. Go through the list of pingbacks, identifying and deleting any spam or irrelevant entries.
  5. For large amounts of spam, select multiple pingbacks and, from the Bulk Actions drop-down menu, choose Spam or Trash to remove them in bulk.

Delete pingbacks and trackbacks in the database

You can delete pingbacks and trackbacks in bulk through phpMyAdmin. Here's how to do it.

  1. Access your database through phpMyAdmin.
  2. Navigate to the SQL tab and execute the following query:
    DELETE FROM wp_comments WHERE comment_type IN ('pingback', 'trackback');
    Note: wp_ is the default database table prefix. If your table prefix isn't wp_, find your table prefix and use that in your query. Example: wp_xufdzp_comments.
  3. Select Go.

Back to top

More info