I've got a model that's migrating sucessfully but is taking 15-20 seconds. (Obviously this is going to have to be done as a background task not at startup or my app will timeout.)
A 20 second delay, regardless of where it's being done, is bad user experience. I've been looking at the SQL output of the core data migration to see where the major bottlenecks are and I've found this interesting statement
UPDATE ZSIZE SET Z_ENT = ( CASE WHEN Z_ENT = 9 THEN 10 ELSE Z_ENT END ) WHERE Z_ENT IN (9)
This statement seems to be taking 5 seconds (and there are others for the other tables in my db).
Surely because of the IN (9)
at the end of the statement it doesn't need to run a case statement per row in the table?
Why doesn't CoreData just run this statement instead?
UPDATE ZSIZE SET Z_ENT=10 WHERE Z_ENT = 9
For bonus points, any other tips / hints about optimizing coredata migrations would be much appreciated!