My ios application use FMDB framework to work with SQLite database. For updating database from server I use FMDatabaseQueue:
- (BOOL)executeUpdate:(NSString *)update
{
FMDatabaseQueue *dbQueue = [FMDatabaseQueue databaseQueueWithPath:databasePath];
__block BOOL success = NO;
[dbQueue inTransaction:^(FMDatabase *db, BOOL *rollback) {
success = [db executeUpdate: update];
}];
return success;
}
This approach allow me use multiple threads for working with database. But queries will be executed in the order they are received. When I update the big piece of data in database other queries(like getting some data for UI thread) must wait too long. Is there a way to allow other queries read commited data while updating is in progress?(Like JDBC Isolation level TRANSACTION_READ_COMMITTED)
Reducing the isolation level works only in shared cache mode, which does not make sense on a mobile device.
To increase concurrency, i.e., to allow readers and a writer to access the database at the same time, enable WAL mode.