I have an iOS app, with a table that has 1500 records.
I'm using FMDB, invoking the following form:
FMDatabase *db = ...
[db executeQuery:@"select num from a where b = ?", 6];
The table "a" has an index on "b".
This runs fine in the simulator, but on an iPad1 is taking a very long time. It consumes memory until the app is killed. Instruments says its stuck in "sqlite3_prepare_v2".
The original query also had an "order by" clause. I've removed it to test. I can even completely remove the where clause and it still behaves this way.
Any ideas what might be wrong?
Other queries are working before this occurs. I have previously accessed the database from a different thread, but there is no access from any other thread going on. I had thought I might have a dangling transaction, but that isn't the case either.
I think I've found the problem. I have two threads and have a FMDatabase object for each thread. What I believe happened is that I had inserted many rows using the 1st database object in a transaction. I had a logic error where I never committed the transaction.
While the 1st database instance had this large pending transaction, I'm attempting to select all from the same table from a second database instance.
Apparently that caused the situation. Apparently in the simulator, it wasn't noticeably slow. But it consumed enough memory and time on the iPad1 that the app was killed.