5

I am developing an application for IPhone and using sqlite to connect to db. I am trying to use the singleton pattern for connecting to the db and retrieving the data.

I would like to know which is the best way to maintain the connection, should I keep the connection open till the application is closed or should I open and close the connection for every call that I make ?

1 Answer 1

7

SQLite must re-parse the database schema each time a new connection is made. This can be time consuming. Leaving the connection open also provides opportunities for SQLite to cache data. Since you get ACID transactions even without closing the connection, there is little reason to close it. So, keep the SQLite connection open until the application is closed.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.