Core Data sqlite-wal file gets MASSIVE (>7GB) when inserting ~5000 rows
It seems my comment to try using the old rollback(DELETE) journal mode rather than WAL journal mode fixed the problem. NOTE that there seem to be a range of problems when using WAL journal mode including the following:
- this problem
- problems with database migrations when using the migratePersistentStore API
- problems with lightweight migrations
Perhaps we should start a Core Data WAL problems page and get a comprehensive list and ask Apple to fix the bugs.
Note that the default mode under OS X 10.9 and iOS 7 now uses WAL mode. To change this back add the following option
@{ NSSQLitePragmaOptions : @{ @"journal_mode" : @"DELETE" } }
All changed pages of a transaction get appended to the -wal
file.If you are importing multiple records, you should, if possible, use a single transaction for the entire import.
SQLite cannot do a full WAL checkpoint while some other connection is reading the database (which might just be some statement that you forgot to close).