Opening connection to SQLITE database on iPhone too slow

Go To StackoverFlow.com

0

I have created a simple iPhone/iPad app which reads some data from a SQLITE database and shows it on the screen. The database is added to the Xcode project and only needs to be read (not written). In the simulator all this works fine, but when I run this app on my iPhone it is too slow.

I have added some performance profiling to the app, so I was able to determine which part of the app was slow. It appears that opening the connection to the database takes about 0.8 - 0.9 second on the iPhone and about 0.004 second on the iPad. I tested with the SQLLITE framework and also with the FMDB wrapper, but the results were the same.

Why is it so slow on the iPhone? Is there a way to improve the performance?

Thanks, Danny

2012-04-05 19:38
by dennieku


0

How often are you opening it? If you can open it once, and just keep that handle open and reuse it, that would likely solve your problem.

Or is it that this single instance of it opening is too great of a burden?

2012-04-05 20:36
by ccgus
Yes, that is probably a solution. But, I have read that it is better to always immediately close a database connection. In this case I am wondering what the best practice is - dennieku 2012-04-06 05:44
Ads