Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
82 views
in Technique[技术] by (71.8m points)

python - Sqlite3 'BEGIN CONCURRENT' and 'WAL2'

Hoping I have a simple question here. I am trying to utilize the BEGIN CONCURRENT enhancement in sqlite3 https://www.sqlite.org/cgi/src/doc/begin-concurrent/doc/begin_concurrent.md#:~:text=Overview,system%20still%20serializes%20COMMIT%20commands. In order to allow multiple writers concurrently on the same database file. These writers will never write to the same table in that database.

The issue I am having is that sqlite does not seem to recognize 'WAL2' (only legacy 'WAL') as a journal_mode option or the 'concurrent' keyword following a 'begin' statement.

sqlite version:

sqlite> select sqlite_version();
3.31.1
sqlite>

WAL2 Failure:

sqlite>  PRAGMA journal_mode;
delete
sqlite>  PRAGMA journal_mode=WAL2;
delete
sqlite>  PRAGMA journal_mode=WAL;
wal
sqlite>

begin:

sqlite> begin;
sqlite>

begin exclusive:

sqlite> begin exclusive;
sqlite>

begin concurrent:

sqlite> begin concurrent;
Error: near "concurrent": syntax error
sqlie>

It would be great to have this concurrent writing functionality as each time a job is run a new database is created and multiple tables will be created inside this new database. Running these create and insert statements in parallel would greatly reduce runtime and as I said I am not worried about conflicting writes as every writer is writing to their own table. Ideally one job will have many writers at runtime and a queue of commits (or a single commit statement once all writers are finished?) as I understand commits still need be serialized.

Another thing to mention is in production this will all be executed with the python sqlite-db-api. I know that the python sqlite api does some things by default in the background. If there are any considerations I should know about when trying to use this api to perform these writes I would love to be informed.

Let me know if I can clarify the issue in any way. I appreciate the support.

question from:https://stackoverflow.com/questions/65926476/sqlite3-begin-concurrent-and-wal2

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...