This project is read-only.

Removing spam comments and users from an Orchard database

Topics: Administration, General
Mar 5, 2015 at 11:06 AM
I'm returning to a customer's Orchard site that I set up for them about a year ago. The site has started to run very slow and I've found that they have over 100,000 spam comments and registered users. The comments and users aren't approved, but the size of these tables does seem to be slowing down the site. (Particularly the user one when someone is logged in.

I'd like to delete them using SQL from the database.

I could use:

DELETE FROM Orchard_Users_UserPartRecord WHERE EmailStatus = 'Pending';
DELETE FROM Orchard_Comments_CommentPartRecord WHERE EmailStatus = 'Pending';

But I think this will leave orphaned records in tables such as Common_IdentityPartRecord.

What is the correct way to delete these records completely. This site uses the old style database, but it would be good to know how to do it with both the old and new database.