var request = NSBatchUpdateRequest(entityName: "Pokemon");
request.propertiesToUpdate = ["level" : 100]
request.resultType = NSBatchUpdateRequestResultType.UpdatedObjectsCountResultType
let result = self.managedObjectContext.executeRequest(request, error: nil) as NSBatchUpdateResult;
result.result // number of row update
Made a simple test creating 100000 Pokemon and the results are:
Operation
Time
Insert
37.096 seconds
Update
0.363 seconds
Delete
0.135
I have also tried update the record without batchUpdate and as expected it's necessary to save the context more than one time (for the test every 1000 entities) and the result is 17.296 consuming a lot of memory and CPU. The good news is that deleteAll has been implemented well
We could add batchUpdate with few lines of code
Made a simple test creating 100000 Pokemon and the results are:
I have also tried update the record without batchUpdate and as expected it's necessary to save the context more than one time (for the test every 1000 entities) and the result is 17.296 consuming a lot of memory and CPU. The good news is that deleteAll has been implemented well
We should add at least:
I think that with predicateBuilder we can remove the possibility to find/delete/update using attribute
Any suggestions?