When should I do certain SQLite operations on another thread(not the main thread)?

General rule for everything: If it’s fast enough, do it on the main thread. If not, use a worker thread.

Unless you have a ridiculously huge database, a single operation almost never warrants a separate thread. Databases in general are designed to scale well, but of course a very big database (10,000+ rows?) will be a bit slower than a small one. 30 rows, however, is nothing.

I would start threading stuff if you have a lot of operations going on, like a bunch of queries, or complicated queries that span several tables.

As with everything – profile your app, and if it’s too slow, optimize. Don’t write an awesome synchronized super-duper multi-core-ready database handler if none of your queries takes longer than 2ms.

Leave a Comment