Use code BLACKFRIDAY through Dec. 1st for 30% off!

How to optimize your WordPress database (a few simple clicks)

Optimizing your WordPress database is important when it comes to keeping your site healthy and running fast. Over time things like this can easily start to add up to hundreds of thousands of rows. We’ve seen this more times than we can count! Just like you would oil and maintain your car, you should also do it with your WordPress site’s database.

Another reason is that an evergrowing database could cost you more on disk space with your hosting provider. So optimizing can also be a way to save money. Because of this, we have many ways in our Perfmatter’s plugin to clean up and delete leftover data, such as revisions, auto-drafts, spam comments, transients, and more.

A huge problem today is that some of the database optimization plugins out there are bloated and cause performance issues on the back-end. Some are even on hosting provider’s banned or disallowed lists. We’ve developed ours to be as lightweight as possible, while still giving you the options you need.

Click on any of the links below to jump to the more in-depth documentation on how to perform each individual optimization. Our biggest goal was to keep this feature simple and fast.

Schedule optimization

Don’t have time to go through each optimization on a regular basis? No worries, we have a built-in scheduler you can use.

Important: These functions make permanent changes that cannot be reverted! Back up your database before proceeding.

Step 1

Click into the Perfmatters plugin settings.

Perfmatters settings
Perfmatters settings

Step 2

Click the “Extras” tab and then click “Database.”

Perfmatters Database
Perfmatters Database

Step 3

Select the database optimizations you want to run on a schedule. You can click into the tooltip on each optimization to learn more about them.

WordPress database optimizations
WordPress database optimizations

Step 4

Scroll down and under “Scheduled Optimization,” select the frequency at which you want it to run: Daily, Weekly, or Monthly. Note: This default is set to disabled.

Setting a new schedule will run the database optimization process immediately after saving your changes. This is performed with a background process and cron job in WordPress.

Step 5

Click “Save Changes.” You can go back in there at any time if you need to change or disable the schedule.

Filter for HTTP Basic Auth (.htpasswd)

If you have HTTP Basic Auth (.htpasswd) protection on your WordPress site, you will need to add the filter for the database optimization process to function properly.

We recommend adding it with the free Code Snippets plugin. Make sure to update the USERNAME and PASSWORD strings accordingly.

function wpbp_http_request_args( $r, $url ) {
	$r['headers']['Authorization'] = 'Basic ' . base64_encode( USERNAME . ':' . PASSWORD );
	return $r;
add_filter('http_request_args', 'wpbp_http_request_args', 10, 2);

Was this article helpful?

Related Articles