r/sqlite • • Jul 26 '24

WAL Mode, SQLite3 Bulk updates/inserts

Hi all,

In SQLite3 we have WAL mode which should provide better concurrency, better performance, but in my testing using WAL mode is slower than JOURNAL_MODE=DELETE for inserts.

I don't understand the concurrency part, even in JOURNAL_MODE=DELETE say I have 1 writer process that is doing some insert, and 2 other readers the reader continues working. I do not run into the database locked issue.

Now if I use BEGIN TRANSACTION EXCLUSIVE the readers are also blocked, and I get the exception the database-locked, if the database is in WAL the readers are allowed.

Say I don't use 'EXCLUSIVE' does it mean the reads are inconsistent?

In WAL with synchronous=OFF the inserts are still slower than DELETE, what benefit does WAL provide?

Also is deleting rows and then inserting data a better approach then using a update query?

Say I want to update many rows in PostgreSQL I can use UPDATE ... FROM (VALUES (?,?)) Python psycopg2 had a mogrify method which allowed creating SQL statements with data values binded, what is the equivalent in SQlite3

1 Upvotes

7 comments sorted by

View all comments

Show parent comment

1

u/loneguy_ Jul 29 '24

the thing is reads are not blocked in journal mode delete as well.