How to reduce database size

Let’s say I wanted to slim down the DB a tad by deleting 1000 topics from a category. Basically deleting topics that get no attention or have no reason to be up anymore. From my understanding, even if I delete these 1000 topics, it won’t have any effect on the database size what-so-ever, as nothing gets truly deleted with discourse, yes? How do bigger sites manage when they clean up unwanted posts if true.

1 Like

They don’t take up much room. If it were 20 years ago, this might be an issue. If your site had 1, 000,000 topics and you wanted to delete 800,000 then you might have a problem to solve.

4 Likes

I’d like to know how to do this as well.

I want to create a category that auto deletes posts. The idea is to have a space where people can speak freely knowing that whatever they post will auto delete after a certain time i.e. for privacy reasons.

I have a category set to auto close topics after 168 hours.
Now I need to figure out how to delve into the DB (I expect a crontab task is the best way to do this) and delete any posts including uploaded images from the server that belong to this category and are auto closed.

How would I do that?

A plugin could destroy the deleted posts. If privacy is the concern then there could be reason to do this. It still assumes that you don’t have backups.

1 Like

That depends on the post type. 90% of my topics have at least two uploads in them, it adds up very quick.

But uploads aren’t stored in the DB, and on the op you talk about

5 Likes

Sorry I guess I made a mistake expressing myself. Just wanted to know if there is a easy way of slimming down the overall size of my instance in a easy way.

Is there a simple way to delete auto closed posts from a specific category via the linux commandline? (I’m not a programmer).

If disk space on the server is your issue, you could move images to S3.

You could use a rails console command to delete closed topics in a category.

3 Likes