0
我有2個核心數據模型與相同數量的表/行。我剛更名了幾行(不添加新行)核心數據遷移是否依賴於已編輯的錶行數量?
核心數據遷移緩慢程度與已編輯的錶行數成正比嗎?還是僅僅取決於數據庫有多大?換句話說,如果我在兩個完全相同的模型之間遷移(所有的字段都是自己製作的),遷移應該是非常快的,還是取決於模型的大小?
感謝
我已經上傳轉換日誌:http://cl.ly/3H1v252R1p1c
PS。不知道爲什麼我有幾行CREATE/INSERT語句,即使我沒有更改數據庫中的任何表。我剛剛添加了一個新表到我的數據庫,我沒有將它映射到以前的數據庫中的任何表。
這是代碼(我試圖改變所有的參數,並刪除pragmaOptions,但它始終是慢
NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"DBname.sqlite"]];
NSError *error = nil;
NSMutableDictionary *pragmaOptions = [NSMutableDictionary dictionary];
[pragmaOptions setObject:@"OFF" forKey:@"synchronous"];
[pragmaOptions setObject:@"0" forKey:@"fullfsync"];
NSDictionary *storeOptions = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:NO], NSInferMappingModelAutomaticallyOption,
NSSQLiteStoreType, NSStoreTypeKey,
pragmaOptions, NSSQLitePragmasOption,
nil];
persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
[persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:storeOptions error:&error];
UDPATE:例可疑重新插入
2013-06-13 09:38:44.114 MyApp[7415:907] CoreData: sql: INSERT INTO ZITEM(Z_PK, Z_ENT, Z_OPT, ZSECTION, ZUNIQUEID, ZBIN, ZDISPLAYNAME, ZSORTNAME) VALUES(?, ?, ?, ?, ?, ?, ?, ?)
2013-06-13 09:38:44.116 MyApp[7415:907] CoreData: details: SQLite bind[0] = (int64)8
2013-06-13 09:38:44.117 MyApp[7415:907] CoreData: details: SQLite bind[1] = (int64)8
2013-06-13 09:38:44.118 MyApp[7415:907] CoreData: details: SQLite bind[2] = (int64)1
2013-06-13 09:38:44.120 MyApp[7415:907] CoreData: details: SQLite bind[3] = nil
2013-06-13 09:38:44.121 MyApp[7415:907] CoreData: details: SQLite bind[4] = 119
2013-06-13 09:38:44.123 MyApp[7415:907] CoreData: details: SQLite bind[5] = 0
2013-06-13 09:38:44.124 MyApp[7415:907] CoreData: details: SQLite bind[6] = "PG-13 (Parents Strongly Cautioned)"
我沒有改變我的數據庫中的任何東西,但我實際上有幾個INSERT語句。不知道爲什麼。 – aneuryzm
這是轉換日誌:http://cl.ly/3H1v252R1p1c – aneuryzm
@Patrick:您是否執行輕量級遷移或顯式遷移?也許你可以展示與創建模型和持久存儲相關的代碼。 –