If you compile with SQLITE_THREADSAFE=1 then multiple calls from different threads will be serialized by SQLite.
"Serialized" means that only one thread at a time will be allowed to run within SQLite; API calls from other threads will block until the currently running thread returns. If your application uses virtual tables implemented with native tables, then there may be an issue with deadlocks (appl -> sqlite3_step -> virtual table code -> sqlite3_step would cause the same thread to recursively enter SQLite). Progress will generally not be faster than using a single threaded approach, unless there is a lot of processing going on outside of SQLite. Sharing one connection between different threads means the threads also share the (implicit or explicit) transaction, i.e. in simple terms, changes written by one thread will immediately be visible to all the other threads and will only be committed if/when the "outermost" transaction commits. From my reading of the interface spec I can't see that registering an update hook is only allowed on one connection per process. Indeed, there is a parameter to identify the connection the hook should be registered to, which would be rather pointless if only one hook per process were allowed. -----Ursprüngliche Nachricht----- Von: prashantbkdhas [mailto:prashant.d...@gmail.com] Gesendet: Samstag, 31. Mai 2014 00:25 An: sqlite-users@sqlite.org Betreff: [sqlite] Multiple reads and writes to a single DB connection from multiple threads Hi,I looked at a few of the multithreading docs and posts and it looks like SQLite3 supports reads and writes from multiple threads provided SQLite3 is compile with THREADSAFE option. In this case each thread has it own DB connection. My question is if I have a single DB connection which is used by multiple threads then are simultaneous reads and writes supported from these threads. I understand writes will lock the DB but other than this will this work. Basically are there issues if a read is happening on the DB connection can another read happen in the same DB connection from another thread. On the same thread this is not an issue. I was wondering whether there could be issues when doing from multiple threads.The reason I am sharing a single connection with multiple threads is because I need to listen to the DB change notification. Currently SQLite3 supports listening to notifications from a single connection only. For this reason I am maintaining a single connection shared by multiple threads.ThanksPrashant -- View this message in context: http://sqlite.1065341.n5.nabble.com/Multiple-reads-and-writes-to-a-single-DB-connection-from-multiple-threads-tp75972.html Sent from the SQLite mailing list archive at Nabble.com. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ----------------------------------------------------------------------- Gunter Hick Software Engineer Scientific Games International GmbH Klitschgasse 2 – 4, A - 1130 Vienna, Austria FN 157284 a, HG Wien Tel: +43 1 80100 0 E-Mail: h...@scigames.at This e-mail is confidential and may well also be legally privileged. If you have received it in error, you are on notice as to its status and accordingly please notify us immediately by reply e-mail and then delete this message from your system. Please do not copy it or use it for any purposes, or disclose its contents to any person as to do so could be a breach of confidence. Thank you for your cooperation. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users