26
Apr
2009



Bookmark and Share

wordpressPost Revision is a nice feature in WordPress 2.5 + letting you save multiple drafts of your posts. This is particularly useful if  your blog has got different authors editing the same posts, or if you are so inattentive to delete important paragraph from your articles.  Basically, the Post Revision feature allows you to  see what was changed in a post, by whom and when, and revert it to a previous state if necessary. Now, if you are the sole  author blogger in your website, this feature may be not that useful. Let’s learn how to make your database more efficent by disabling or limiting it!

You might think: “What the heck does my database have to do with Post Revision?”. Simple,  every time a post is edited, this little function adds a new row in the wp_posts table of your database ending up with clogging it. So, if  for example, you edit  a post  10 times, you will have 10 new rows in wp_posts table!  Here are some hacks to limit or disable it.

Clean your database

This is the first step to do if you want to get rid of all the junk Post Revision pestered your database with. To do it, simply go to your Cpanel, click phpMyAdmin and run this query:

DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = ‘revision’

Note that, despite this query has never, ever troubled anybody, it is always advisable to back-up your database first.

Disable Post Revision

To do it, simple login your FTP server, go to public_html and add the following line to wp-config.php, also making sure to place it between “<?php” and  “?>”:

/ /disable the painful post revision feature
define(‘WP_POST_REVISIONS’,false);

Limit Post Revision

Again, login your FTP server, go to the public_html folder and add the following line to wp-config.php, also making sure to place it between “<?php” and  “?>”:

/ /disable the painful post revision feature
define(‘WP_POST_REVISIONS’,6);

The example above limit the number of Post Revision to six.

Incredibly to say, these hacks managed to improve my database a lot,  also reducing the number of slow queries it produced. Before applying these tricks my database was about 2000 Kb. After using the Clean your Database hack, it was only 1046 Kb!




Related Articles Latest Articles
.

One Comment to “How to turn off Post Revision in WordPress and optimize your database”

  1. abhi Says:

    Nice trick man. It is working perfectly am really facing a hestic problem with this revision posts. Thumbs up and Keep up.


Copyright © 2007-2017 | Sitemap | Privacy | Back To Top
Best screen resolution 1280x800 or higher.
Web Talk is best viewed in Firefox.

Stat