optimize-database

 

8. Optimize Your Database

You can optimize your WordPress MySQL database directly from PHPMyAdmin, or by using a plugin like WP-Optimize or WP-DBManager.

These plugins are capable of deleting all your pending spam comments, trashed posts, auto-saved drafts, post revision to name a few. They can also perform general MySQL database optimization queries without you having to access PHPMyAdmin.

A well optimized, fast responding database is a huge bonus for a database-driven software like WordPress.

Empty your trash

With the WordPress trash system. Whenever content is deleted, be it a comment, post, page, media etc; it is sent to trash. From here, the content can either be restored or deleted permanently. It is effectively a fail-safe system that helps you recover anything that was deleted accidentally ( in much the same way the recycling bin works in your computer).

Trash can take up a lot of unnecessary room in your website’s database. The bigger the database, the longer it is to retrieve information from it.

By default, WordPress will automatically delete trash after thirty days. You can reduced this by modifying the wp-config.php file. For example, you could reduce this to seven days by adding the following:

define (‘EMPTY_TRASH_DAYS’, 7);

You can completely disable the trash system by adding following code:

define (‘EMPTY_TRASH_DAYS’, 0);

Turn-off trackbacks & pingbacks

Trackbacks and Pingbacks are’nt good for your site speed. Whenever someone links to you, a trackback gets created, utilizing server and database resources.

So, unless absolutely necessary, you can simply disable trackbacks and pingbacks from WordPress’s Discussion Settings.

You should also be wary of the number of drafts and post revisions your website has stored. The WordPress revision system allows you to go back to older versions of articles, view them and restore them.

In addition to one autosave of your posts and pages, each time you save your articles, it will generate revisions. This means that an articles with ten revisions with take up ten times as much room on your databases than the actual article.

By default, WordPress will save an unlimited number of revisions, however this is often not necessary. It is better to reduce this limit to something more practical such as two or three.

You can do this by adding the following code to your wp-config.php file :

define( ‘WP_POST_REVISIONS‘, 3 );

Alternatively, you can completely disable the post revision system by adding the code below to your wp-config.php. From a blogger’s perspective, this is not an optimal setting when post revisions are useful.

define( ‘WP_POST_REVISIONS‘,  false);

A more practical way of cleaning your WordPress databased is to use WP Optimize. The plugin can automatically remove auto-drafts, spam comments, trackbacks and more. WP-DBManager is also a good solution for solution for optimizing your database.