What is the fastest way to delete a list of +- 50 000 records.

3
What is the fastest way to delete a list of +- 50 000 records. Ive tried by looping over a list and deleting the records one by one but this takes forever. We've tried adding the list to a batch job in java but this also takes about 30 mins. Is there a faster way? Pls help
asked
6 answers
2

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

answered
6

File a feature request for a "delete by xpath" Core API function :)

answered
3

IRemoveBatch batch = Core.removeBatch(this.getContext(), EntityObjectList.get(0).getMendixObject().getType(),5000, true, true);

          for(EntityObject g : EntityObjectList)      {

      batch.removeObject(g.getMendixObject());>       }
                  batch.commit();
answered
2

The Community commons library has a functions for this

answered
2

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. 

answered
0

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:

  • Retrieves a batch of 1000 (or so) objects
  • Deletes the objects
  • Calls the EndTransaction java action (from CommunityCommons)

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.

answered