Optimize WordPress Database

How to Optimize WordPress Database?

Optimizing your WordPress database is important when it comes to keeping your site healthy and speed up loading. Over the time database started increasing and adding thousand of rows and columns. We’ve seen this more than we can count! Just like you would servicing and maintain your car, you should also do it with your WordPress site’s database. So, you need to know how important is to Optimize WordPress Database.

WordPress is a fantastic, fast and powerful blogging and business software. But sometimes things do not work as expected and can result in performance problems or database errors. This article will show you how to optimize the WordPress database, and what changes can be made to improve the system’s stability and performance under the control of an expert.

How to Schedule Database Optimization?

Don’t have time to run through each optimization on a regular basis? No worries, we have the right solution for you!

Step 1

Click into the Perfmatters plugin settings.

Perfmatters Settings

Step 2

Under the “Tools” section, click on the “Database” menu.

Perfmatters Database
Perfmatters Database

Step 3

Select the database optimizations you want to run on a schedule. You can click on 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 to run automatically: Daily, Weekly, or Monthly. Note: This is set to disabled by default.

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

WordPress Database Scheduled Optimization
WordPress Database Scheduled Optimization

Step 5

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

CRON Job

Database optimization feature uses a background automation process to a cron job schedule at the end of it to confirm the cleanup has finished. You can use a real cron (or server-level cron); it just means that the UI message in the Perfmatters plugin settings might remains for a long time after running to confirm cleanup has finished. The timing would depend on what you have set for the database optimization schedule.

The cron will run based on the scheduled action you set, lets say daily, weekly, etc. Starting from the time you set it up for optimization. If you run a manual optimization, the schedule already set will remain the same.

Filter for HTTP Basic Auth (.htpasswd)

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

We recommend 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);

Read More: Top 7 Databases You Should Learn in 2021

Rahul Sharma

Rahul Sharma is a Founder of Logical IDEA and Bee Flirty. He is a Professional WP Developers, UX Designer, and Digital Marketing Expert. Previously, He Worked as a Digital Marketing Head for An eCommerce Startup. He Graduated with honors from Lovely Professional University with a Dual Degree in Information Technology.

Leave a Reply

Your email address will not be published.