Basic speedup and transactions
(1) By Andrzej on 2022-08-08 03:55:24 [source]
Reading database is always fast, whereas to speedup writing is needed many writings in one transaction? I haven't used sqlite for a long time and forgot a bit how do it. Where I can find simple C/C++ code for begin transaction + writings + end transaction? Sorry for obvious question...
(2) By anonymous on 2022-08-08 04:57:47 in reply to 1 [link] [source]
https://stackoverflow.com/questions/1711631/improve-insert-per-second-performance-of-sqlite
(3) By Stephan Beal (stephan) on 2022-08-08 05:04:08 in reply to 2 [link] [source]
...1711631/improve-insert-per-second-performance-of-sqlite
@OP: note that that article is ancient by any standards but the core APIs it uses there are still valid. sqlite has a high level of backwards compatibility.
(4.1) By Simon Slavin (slavin) on 2022-08-08 10:12:04 edited from 4.0 in reply to 1 [link] [source]
Transactions are handled using SQL commands, not with C calls which work outside SQL. To start a transaction use the BEGIN command. To end one use END or COMMIT (which are exact synonyms) to execute all the commands in the transaction, or ROLLBACK to abandon the transaction.
Each of these commands can be looked up on the SQLite site, but here are two pages which you might find useful to start with:
https://www.sqlite.org/lang_transaction.html
https://www.sqlite.org/quickstart.html
SQLite can't do any data access (reading or writing) outside a transaction. If you don't define your own, you are not saving lots of time by not creating a transaction, since SQLite will helpfully wrap your command in BEGIN and END so it can execute it.