SQLite Forum

WAL journal and threading mode
Login
In my application there is an intensive usage of the database from a multi-threading environment. <br>
Until now my sqlite configuration was: **journal-mode=DELETE** (DEFAULT), **synchronous=FULL** (DEFAULT), and threading-mode **MULTITHREAD(2)**, where each thread is using its own connection.

I created a stress unit-test application that WRITEs from many threads, each thread with its own connection. While testing performance I found that when **journal-mode=WAL** and **synchronous=NORMAL** the performance goes much higher but also the CPU goes high (up to 90%). I will emphasize here that I implemented **sqlite3_busy_handler** that always returns true, but every 100 retries sleeps for 1 ms.

My question is about the combination of WAL journal and threading mode:<br>
Assuming that WAL journal takes care of locks over the database (?) do I need also to manage synchronization using threading mode? <br>
What will happen if I use WAL|NORMAL with zero multi-threading protection: **SQLITE_CONFIG_SINGLETHREAD (SQLITE_THREADSAFE=0)**?

Many thanks for this clarification.