Support Forum

Prune Database Request

31 Answers

New Answer

YS Yellow Swordfish
Yellow Swordfish
Member

What? 10620? Oh my. I need to think about that one! We might need to devise a SQL script for something like that. Let me ponder for a while.

MY My
My
Member

Yellow Swordfish said
What? 10620? Oh my. I need to think about that one! We might need to devise a SQL script for something like that. Let me ponder for a while.

heh… what can I say.. people like to chat LOL

After a few threads got that long we started locking them down and starting new ones but there’s half a dozen like that

YS Yellow Swordfish
Yellow Swordfish
Member

If I write up some SQL queries are you able and willing to run them directly in the database? I just might not be able to do that today…

MY My
My
Member

I missed this reply … was just checking to see if there was any progress.. yes, I’m happy to run them in the database

YS Yellow Swordfish
Yellow Swordfish
Member

Deleting in batches will be a pig of a development issue and wont be quick I am afraid. But I should be able to get some base queries to you.

I do need to know if you are using the latest versions of everything as that will make a big difference.

MY My
My
Member

WordPress version 4.1.1

Simplepress version 5.5.5

All other plugins are up to date as of right now.

YS Yellow Swordfish
Yellow Swordfish
Member

This – as far as I can tell without spending a week testing and analysing! – should do the trick. I am only concerned that it might leave a record behind here and there but nothing, I believe, that would cause any concern. Just perhaps the odd orphaned row.

So this is a series of queries you can run directly:

DELETE FROM wp_sfdigest WHERE topic_id = XXXXX;
DELETE FROM wp_sflinks WHERE topic_id = XXXXX;
DELETE FROM wp_sfpostattachments WHERE topic_id = XXXXX;
DELETE FROM wp_sfposts WHERE topic_id = XXXXX;
DELETE FROM wp_sftagmeta WHERE topic_id = XXXXX;
DELETE FROM wp_sftopics WHERE topic_id = XXXXX;
DELETE FROM wp_sftrack WHERE topic_id = XXXXX;
DELETE FROM wp_sfwaiting WHERE topic_id = XXXXX;
DELETE FROM wp_sfuseractivity WHERE type_id=1 AND item_id = XXXXX;
DELETE FROM wp_sfuseractivity WHERE type_id=6 AND item_id = XXXXX;
DELETE FROM wp_sfuseractivity WHERE type_id=5 AND meta_id = XXXXX;

IF you do NOT use the blog linking plugin then remove the ‘sflinks’ query.
IF you do NOT use the tags plugin the remove the ‘sftagmeta’ query.
IF you do NOT use the watch plugin then remove the ‘sfuseractivity’ query where type_id=1.
IF you do not use the post rating plugin then remove the ‘sfuseractivity’ query where type_id=5.
IF you do NOT user the subscriptions plugin then remove the ‘sfuseractivity’ query where type_id=6 AND the ‘sfdigest’ query.

Replace the table prefix ‘wp_’ if this is not what you use.

Replace the XXXXX with the topic ID you wish to remove – in each query.

As always we recommend a full database backup be made prior to using these queries. And, I am afraid, as always we offer these queries with no guarantee of success or effect.

MY My
My
Member

That appears to have allowed me to delete the topics in question. I don’t supposed there’s a way to update the forum stats though is there? Running the stats update cron doesn’t do it

YS Yellow Swordfish
Yellow Swordfish
Member

Ah I knew there would be something±

In the sfforums table is a column called ‘topic_count’ and another called ‘post_count’ which wont get adjusted. In many respects this is, of course, not perfect db management but it actually makes such a huge difference to overall performance that having these value is worthwhile.

We will need another couple of queries to update these values at the end of the deletes,

MY My
My
Member

Users are reporting that forum posting is going a little faster now so I’m hoping this has all been worthwhile even if the stats are no longer accurate :)

YS Yellow Swordfish
Yellow Swordfish
Member

Go to the forum admin > toolbox > housekeeping and run the ‘Rebuild Forum Indexes’ against the forum that had the topic(s) manually removed. That should repair the stats count data which should then correct themselves when the stats Cron action is performed.

MY My
My
Member

Yellow Swordfish said
Go to the forum admin > toolbox > housekeeping and run the ‘Rebuild Forum Indexes’ against the forum that had the topic(s) manually removed. That should repair the stats count data which should then correct themselves when the stats Cron action is performed.

I already tried that but I just get an endless “Please wait…”

YS Yellow Swordfish
Yellow Swordfish
Member

Yes – I can see even that might take a very long time..
Let’s try this instead…

Open the forum in question so you see the list of topics (forum view). Select a topic with a small number of posts and click on the forum tools, Select the ‘View Properties’ option and then click on the ‘verify’ button.

Does that work it out?

MY My
My
Member

View properties ran on one of the smaller topics but it made no difference to the post count.

I left the Rebuild Index thing running for a couple of hours.. it didn’t seem like it was really doing anything

YS Yellow Swordfish
Yellow Swordfish
Member

It made no difference? Even after the stats cron task has run again?