It is actually quit strange, because it takes 2minutes to upload the 50 000 records (using batch create), but 30minutes to delete the same records (using batch remove).
File a feature request for a "delete by xpath" Core API function :)
IRemoveBatch batch = Core.removeBatch(this.getContext(), EntityObjectList.get(0).getMendixObject().getType(),5000, true, true);
for(EntityObject g : EntityObjectList) { batch.removeObject(g.getMendixObject());> } batch.commit();
The Community commons library has a functions for this
If you want to split it up into multiple transactions, doing it in batches in the process queue sometimes is a good Idea.
I also created a module that can split up such jobs in multiple threads. Search for "Follow Up Microflow" in the AppStore. There is also a demo app showing some batch processing examples.
In my experience, the fastest way to delete 300.000+ records is to create a microflow that deletes everything in a loop, where each iteration:
This seems to be faster than the DeleteAll java action from CommunityCommons. It seems to me that the EndTransaction is crucial to keep the hidden administration of to-be-deleted objects lightweight.