SQLite Forum

Fast way to insert rows in SQLite
Login
Beside playing with the `page_size`, there isn't much that can be improved.

The default is 4KB pages these days, and you might gain a little with 8KB   
and 16KB at insertion time, at the expense of more IO later on updates and  
deletes, so there's a balance to find specific to what you are doing.

Note that you `cache_size` is affected by the `page_size`, unless you switch to  
a negative value, for an absolute value in KBs. See [pragma_cache_size](https://www.sqlite.org/pragma.html#pragma_cache_size)

Multi-threading won't help at all on the SQLite side. But you can of course  
prepare all your batches in a separate thread, and use an SPSC queue to pass  
those batches around to the SQLite thread, to at least get some concurrency  
between  the SQLite code, and your own code.

*(But you probably want your queue to be fixed-size and blocking when full,  
to throttle the producer-side, which is going to be (much?) faster than the  
SQLite consumer side actually doing the IO)*

Maybe others will have further suggestions. --DD