Deleting 40K topics


I am trying to delete ~40,000 topics from discourse. The method I use is programming a browser macro service to go to a specific search page in my Discourse site, click on image then select all and click on image and click on the red delete-topics button.
I play this macro in a loop so it deletes 50 posts at a time, but after a few cycles, the site crashes.

Is there a better method?
Why is deleting posts such a heavy task for the server?

How did you get into a situation where you need to delete 40,000 topics? Why are these topics there?

At any rate, you should be deleting them from the command line, browser automation isn’t a good way to approach this.

1 Like

They were created by a script that publishes wordpress posts that creates a matching discourse topic for every wordpress post.

Unfortunately I don’t have the knowledge how to do this in the command line, but I still think that the batch delete can be improved. For example, it lets you choose up to 1000 topics to edit/delete but it can’t handle such a task, perhaps because it tries to do them all at once. Maybe there is a way to do this more sequentially so the server can handle the load. If I could delete 1000 posts at a time, i wouldn’t have a problem doing it manually via the browser, only 40 time for 40K topics.

EDIT: I increased the server power (to 4 cpus, 4GB ram) and restarted the browser automation and it deleted everything within a couple of hours… so in case anyone reads this in the future, it is something you can do if you don’t have command line experience…

1 Like

Can you not restore from a recent backup?

You might search here for ‘rails delete post’ or, if you have a budget, ask for help in #marketplace.


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.