Forums

Delete Post Revisions
Using Delete Post Revisions on a site with W3 Total Cache (5 posts)

  1. obragblog
    Member
    Posted 1 year ago #

    Hi,

    I just ran this plugin on two smaller sites I have and it worked beautifully! Thank you! On one of my sites 80% of the items in the posts table of the database were revisions. A big savings. The plugin ran as expected and generated a list of deleted revisions in both cases.

    I tried to run it on another site which very much larger, and is running W3 Total Cache, but nothing happens. The admin page seems to refresh itself and the browser declares "done" but no list appears and the number of entries in the database is unchanged. On this larger site I changed the wpconfig.php file to limit the number of revisions BEFORE I ran the plugin and thought that maybe that was the problem so I changed it backed to the default and tried again to run the plugin but it still doesn't delete anything.

    Should I try disable the cache plugin first? Any thoughts? Thank you!

  2. obragblog
    Member
    Posted 1 year ago #

    Never mind. I used this query, from Andrei Neculau, in phpmyadmin

    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';

    We run a large site and this stripped 44,000 un-needed records out of our database. Amen.

  3. Donal
    Member
    Posted 1 year ago #

    Hi obragblog. Sorry for not responding to your question. I was transported back to the Stone Age for a couple of days there when my computer went and died on me. Just three days, but I'd already begun wearing furs and building stone circles in the back garden by the time I got it fixed...

    Anyway, I run W3 Total Cache on my own sites and I've never known it to interfere with the plugin, so I don't think that's the problem. As far as I know, there's no reason any caching plugin should interfere, as they should only be caching front end pages, not backend stuff like revisions that are never publicly displayed on the site.

    I suspect the problem in this case was the sheer number of revisions that had built up in your database. The plugin doesn't interface with the database directly; instead it uses WordPress's get_posts() function to grab all the revision copies from the database, then deletes them using another standard WordPress function, wp_delete_post().

    Using WordPress's own functionality like this is a safe way to delete stuff from the database, but thinking about it now, this approach will probably fall down when it's confronted by literally tens of thousands of revision posts. In a case like yours, it's much more efficient to interface with the database directly and delete the revisions with a SQL command like you did.

    It is amazing how quickly the revisions can build up - I usually manage to generate at least 20 for every post I write, correcting typos and the like. There should be a default limit in place - hopefully there will be in some future WP release.

    I'm going to look at the plugin code again and hopefully rewrite it to cope with cases like yours, so the next update should deal with this issue. Thanks for pointing it out - and apologies again for not responding sooner.

  4. obragblog
    Member
    Posted 1 year ago #

    Hi Donal, thanks for getting back. I certainly can relate to reverting to the stone age... been there myself a time or two!

    Thanks too for checking into this. I suspected the issue might be the size of our site, and plan to try and run the plugin again. I set the number of saved revision to 2 so we would have something. I helps when you have multiple people working on a site to have a little backup. I figured I might be able to use your plugin to go in and remove the revisions on posts after they have aged a bit.

    Like I said, I used it on two other sites and it worked perfectly! Good work!

  5. Donal
    Member
    Posted 1 year ago #

    Hi obragblog. I rewrote the plugin's deletion routine today so the new version - 1.2 - should be able to deal with any number of revisions.

    I uploaded it to the repository a couple of hours ago so the new version should be available to download now on your dashboard. If you try it on your site again I'd love to hear back if it worked okay for you.

    Thanks for the feedback!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic