I have a Group domain object that contains a set of user domain objects It is possible for this group object to have 200,000 users.
Whilst testing this, I noticed that deleting this group with groupModel.delete(flust:true) or even deleting all users on the group object groupModel.users.clear() when there were 200,000 users was very slow The group domain object has cascade: 'all-delete-orphan' set for the users
Does anyone have any suggestions on how either of these delete operations can be sped up
You don't want to flush on each delete, that will be horribly slow. Put the delete in a Service / Transaction and just do groupModel.delete(). Keep in mind that deleting 200,000 records plus all the cascades is going to take longer than say, 100 records. But it will be faster if you let Hibernate worry about the flushing instead of forcing it.