I am parsing a ton of data that I originally inserted into the master data warehouse.
In the future, I will parse the same XML, although some of them may have been updated. What I do then is check the existing record with the same tag, and if it already exists, I update the record with data.
However, although my initial parsing (about 11,000 entries) takes 8 seconds or so, the update seems expensive and takes 144 seconds (this simulator works, therefore, much more on real devices).
While the first time is normal (I show the progress bar), the second is unacceptably long, and I would like to do something to improve speed (even if this happens in the background in a separate thread).
Unfortunately, this is not a find-or-create question, since the data in XML can be modified for individual records, so each one may essentially require an update.
I have indexed attributes that speed up the initial parsing and updating, but they are still slow (the numbers above are indexed). I noticed that parsing / updating seems to be slowly slowing down. Although initially fast, it becomes slower and slower as more and more records are processed.
So finally, my question is, do I have any suggestions on how I can improve the speed with which I update my dataset? I am using MagicalRecord to retrieve a record. Here is the code:
Record *record; if (!isUpdate) { record = [NSEntityDescription insertNewObjectForEntityForName:@"Record" inManagedObjectContext:backgroundContext]; } else { NSPredicate *recordPredicate = [NSPredicate predicateWithFormat:@"SELF.tag == %@", [[node attributeForName:@"tag"] stringValue]]; record = [Record findFirstWithPredicate:recordPredicate]; }
runmad
source share