Nelson's log

Deleting iCloud database records is very slow

Wanderings uses iCloud’s private databases as a backing store for data. I wanted to delete some data from them and it is terribly, terribly slow. Roughly 40ms / record.

We’re using this Javascript code to delete records:

CloudKit.getDefaultContainer().privateCloudDatabase.deleteRecords(data)

If the data is 100 records it takes 4000-5000ms to complete. 10 records takes about 400-500ms. So much for batch deletion.

Exacerbating this we had a bug where I was trying to delete 60,000 records at once. This hangs for a very long time and then returns with an error that the operation is too big. Also there was a second bug where we were executing several requests in parallel. This does seem to work but isn’t a good idea. Chrome crashes outright (Oh, Snap) if 26 requests are running in parallel. Firefox didn’t crash but other bad things happened.

So now I’m deleting 60,000 records, 100 at a time every 5 seconds. That’ll be most of an hour.