Why Your WordPress Database Gets So Large and How to Reduce It

Why Your WordPress Database Gets So Large and How to Reduce It

It is not necessary that your WordPress site should be old and extremely active for having a large database. In just a few months, you might start accumulating a lot of data on your site because of posting, adding plugins, commenting, and updating the web pages.

This much growth is essential since your database must store your posts, pages, user profiles, settings, etc. But at times, your database may contain revisions of your post, old spam comments, junk data, and leftover data from deactivated plugins.

It is not just a problem of a large database; unnecessary data, inefficient queries, and poor table structure consume your storage and make your queries slow.

With the help of this guide, you will find out why your WordPress database increases in size, find out what causes the increase in database size, and decrease the database size safely.

Why does Your WordPress Database Gets So Large?

1. Excessive Number of Post Revisions and Autosave Files

WordPress saves a revision every time you edit a post or page, so that you can revert back to previous changes made. These features can be really useful, especially when working on lengthy articles; however, if a website regularly publishes its content, it can accumulate thousands of revisions.

How to minimize them:

  • Use the Database Optimization plugin to get rid of those revisions you do not need anymore.
  • You can also prevent further revisions from occurring by inserting this into your wp-config.php file, after the section that tells you not to edit anything past that point:
define( ‘WP_POST_REVISIONS’, 5 ) ;

This will keep the number of revisions for each post to a minimum of five. However, this does not delete any previously saved revisions.

2. Spam Comments, Queued Comments, and Trashed Items

Comments that are spam, pending moderation, and sitting in the Trash can be stored in your database.

Deleting posts/pages may result in orphaned data that is not deleted when you use some kind of a plugin or a script.

How to solve it:

  • Always review your comments and delete WordPress Trash if you are sure that you will not use these posts anymore.
  • Remember that you have to delete spam and any unnecessary information using the WordPress interface.

Think before you mass delete: Do not mass delete your comments and content without reviewing it to see if you may need them later for any purpose.

3. Expired Transients and Temporary Data

“Transients” is a feature in WordPress and some of your plugins which helps to store some of your data temporarily so that it does not have to be recalculated and retrieved from external sources repeatedly.

Although expired transients should normally auto-expire themselves, sometimes some of them can remain on your database. It should also be noted that plugins may retain some of their transient data in dedicated database tables.

Methods for getting rid of them:

  • Use a good plugin for database cleaning to find and get rid of expired transients.
  • One needs to be careful about active transients – removing active transients will make WordPress create them again from scratch, which temporarily slows down its performance.

4. Excessive data in the wp_options Table

The wp_options table contains WordPress settings and data used by themes and plugins. Some of these settings are autoloaded, which means that WordPress will load these during normal request.

Excessive storage of unneeded information in the autoload table may increase the amount of memory usage and reduce the speed of the site’s response.

It is a very significant difference because having a big database does not necessarily mean having slow page loading, but unnecessary autoloaded data might be a problem.

How to prevent it:

  • Check for any unusually large autoloaded options by means of database analysis tools or a relevant WordPress troubleshooting plugin.
  • Establish the offending plugin before making any changes or deletions.

Do not just blindly remove some options or autoloads. Some may be needed by WordPress itself or any plugins.

5. Plugins with Unnecessary Amounts of Information Stored

There are plugins which create more database entries than site owners know about. Examples include analytics, security, form, backup, and log plugins.

Order information, customer information, session information, and scheduling tasks’ information can also be stored by e-commerce websites. Even after uninstalling the plugin, it is not sure that all tables and settings will also be deleted.

Methods for minimizing data generation:

  • Analyze the plugins that create the most data and see whether those plugins have retention capabilities.
  • Reduce logging to minimum or minimize the amount of time for which logs are stored.

Before deleting tables created by an uninstaller plugin, check to make sure that they are indeed not needed. The logs may have data that is still required by your website.

How to Find Out Which Tables Occupy Database Space

Before performing any database cleanup, find out which tables occupy the most space.

This can be done via phpMyAdmin within your hosting control panel:

  • Examine the tables and check out how much space data and indexes take.
  • Find out what exactly caused their increasing size.
  • Locate the tables with a high amount of space occupied, and also those tables created by plugins.
  • Launch phpMyAdmin and choose the database of WordPress that you have.

Table names should not start with wp_ as WordPress enables you to set your own table prefix.

Having a big table is not an issue per se. For instance, a very active online shop may have legitimate reasons for having lots of order entries. Try to target your activities on eliminating performance bottlenecks and unused data and not deleting tables solely on the basis of their large sizes.

Steps to Decrease Your WordPress Database Size

After determining where your database is getting increased, you have to follow these steps.

1. Deleting Plugin Database Tables with Caution

Examine the database tables generated by previously uninstalled plugins. In case you confirm the fact that a table is irrelevant, go ahead and delete it.

However, do not rush to a decision simply because a particular table does not ring a bell to you.

Some plugins integrate with other products, and others that are responsible for e-commerce and memberships will require this information for the smooth functioning of their processes.

2. Backup Your Database Before You Delete Anything

It is always better to first create a full backup of your database before you start deleting any records and changing table structures. It is wise to keep this backup copy in some other place apart from your website and to test whether the restoration is possible from this backup.

3. Stop Future Database Bloating

Database cleaning is most effective if you combine it with certain maintenance practices:

  • Restrict post revisions: Do not allow WordPress to save too many revision versions.
  • Monitor your database file size: Make sure that any spikes are not there and find out why.
  • Control the log file size: Configure the settings for the logs created by those plugins that generate huge data.
  • Remove unused plugins and themes.
  • Control temporary information: You should regularly review all the temporary information and background processes.

Regular monitoring helps you catch problems before they become difficult to diagnose.

4. Delete Unwanted Information

Use a reputable WordPress database management plugin or well-tested queries in order to delete old revisions, expired transients, spam comments and forgotten drafts. Do it category by category in order to see whether there are no problems and to ensure proper functioning of your website.

Find out more – in the HarmonWeb’s guide to WordPress database optimization.

5. Check Database Table Overhead

The deletion of the records doesn’t necessarily reduce the file size of your database since this greatly depends on your database engine, table structure and your hosting.

Once you have removed all the useless data from your database, check whether there are some tables with high overheads. Having cleaned out the useless information, check for high overhead tables and optimize them using phpMyAdmin.

However, you need to understand that releasing the space in InnoDB tables may take some additional actions from your side depending on the hosting provider. In general, table optimization won’t always reduce your database files’ size.

Will Reducing the Database Size Help to Speed Up WordPress?

Yes, it may help, although it all depends on why the database got its size.

Removing unwanted revisions may help you save some space and improve maintenance procedures, although it won’t help you improve the performance of your website if your actual problem is a slow database query, poor hosting, or too many autoloaded options.

In order to improve, one should find out what the problem is and measure the outcomes after introducing improvements. HarmonWeb’s article on decreasing high CPU usage by WordPress also provides information on the role of database operations in server load.

Conclusion

With time, the database used by your WordPress website will keep on expanding as you publish more information, receive visitors, add features to your site and so forth. However, the expansion might not always be as a result of valid reasons.

The aim is not to shrink your database to its smallest size. Rather, you should eliminate data that is no longer needed by your website but keep all the data it requires to run efficiently.

First of all, start with an audit of your database, where you will find the largest tables, make sure that you have a secure backup, and eliminate unnecessary records (e.g., transients and revisions). Next, watch the growth of storage carefully in order to trace any unusual increase in volume.

Do You Need WordPress Hosting for Your Site?

As your site expands, it is possible that its space and database demands will vary. HarmonWeb can assist you with finding hosting services that will fit your website’s needs.

Choose a web host that is able to handle your traffic and provide your website with the power needed to function efficiently as you grow your visitor base.

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply