0

I am using FMDatabaseQueue to have the ability work with fmdb using GCD. But GCD does not help.

When I try to perform any execute update query several times in one moment I got freeze of application.

To improve the performance I done - complex query to reduce the number of queries - use begin and commit transaction - use setShouldCacheStatements But NOTHING help

Here is some example of code func complexQuery(sqlQuery: String) -> Bool {

var result = false
self.databaseQueue.inDatabase() { database in

    database.setShouldCacheStatements(true)
    database.beginTransaction()
    result = database.executeStatements(sqlQuery)
    database.commit()
}
AstroCB
  • 12,337
  • 20
  • 57
  • 73
Svitlana
  • 2,938
  • 1
  • 29
  • 38
  • perhaps you should `close` and `open` your `FMDatabase`. Please check this http://stackoverflow.com/a/18216818/1866077 – arthankamal Feb 05 '15 at 05:54
  • Please clarify "I got freeze of application". Did the app completely deadlock? Or merely stall momentarily while doing many updates on another thread. Precisely how long are we talking about here? Also, how many updates are you doing in `sqlQuery`? Did `result` indicate successful completion? – Rob Feb 05 '15 at 08:01
  • I have "merely stall momentarily while doing many updates on another thread" freezes. It's near about 4000 updates in 3 queries. The result is successful. Thanks – Svitlana Feb 06 '15 at 00:32

1 Answers1

0

Try call closeOpenResultSets on the FMDB instance just before the execute query

Dryagin
  • 9
  • 2