You pass the request object to the delete method, which will iterate over it in batches, and then send one huge delete. This is inefficient because it requires several samples and will not work if you have more results than you can get in available time or with available memory. The task will either be completed once, or will not require a chain at all, or, most likely, will fail again, since it cannot immediately extract each block.
In addition, the call to count
only executes the query to determine the count, which is a waste of time, since you will still try to get the results.
Instead, you should get results in batches with fetch
and delete each batch. Use the cursors to set the next batch and avoid having to repeat the query on all the βgravestoneβ records before finding the first one alive, and ideally delete several batches per task, using a timer to determine when you should stop and chain the next task.
source share