WordPress, Disable and Delete Post Revisions
Post revisions are one of the more useless features of WordPress that do little but add bloat to the database.
At first they were kind of cool, but then what do you do with them?
You’re not running a wiki. Right?
Here is how to get rid of them once and for all.
Edit wp-config.php, add this line in to disable the post revisions feature.
1 | define('WP_POST_REVISIONS', false); |
You will also need to clean the database of all the previous entries under the wp_posts and wp_postmeta tables.
1 2 | USE database_name; 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'; |
Congratulations, you are done! Enjoy your now much smaller database.
Just note that the simple sql query…
…will not clean out the database completely.
I run that in phpmyadmin and get a timeout… my wp-posts have 120MB
the command crack the database..
It might be all those joins that are causing the problem when done from phpmyadmin (as you have experienced)… Since there is a php script execution limit under php.ini that is relatively short (something like 30-60 seconds).
For future readers: The command-line MySQL shell should not experience this problem.
Note that you can check and repair MySQL tables:
http://dev.mysql.com/doc/refman/5.0/en/check.html
http://dev.mysql.com/doc/refman/5.0/en/repair.html
Very useful article. It worked a treat.
It got rid of all the post revisions.
For anyone who has never done it – -
i used the Query window,
under the SQL tab,
for my wordpress database,
in phpMyAdmin,
in MySQL,
in cPanel,
which most people seem to be able to get into.