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..