WordPress Database Cleaning and Optimization

When you make changes to your WordPress site, WordPress automatically saves the old text. If you have a site with hundreds of content and older versions are stored in each article, this database increases the load and slows down your site. It is possible to solve this problem with only two lines of code and speed up your site a bit.

  • Open your wp-config.php file and add the following codes and save the file.
define('WP_POST_REVISIONS', false );

When you add these codes to your settings file, your WordPress system will not save the old changes you have made to your database in the future.

If you think this feature is useful for me, you can limit the number of versions. The following code sets the maximum number of old versions for a post to four, and you can change the number if you like.

define( 'WP_POST_REVISIONS', 4 );

 

WordPress Database Cleaning

When you run the following SQL code at phpmyadmin page it will automatically delete old versions of the scripts and the database size will be reduced.

DELETE FROM wp_posts WHERE post_type = "revision";

Leave a Reply

Your email address will not be published. Required fields are marked *