SQLite Forum

Increasing insert performance of an in-memory db
Login
How often does the data to be loaded change? If your program will run multiple times with the same data, you can save time with a two-phase approach:

1. When the data changes, run a preprocessing program that creates the database in memory and then saves a snapshot to disk using a <code>VACUUM INTO</code> statement.
2. In the main program, use the backup API to load the snapshot from disk into memory. (This is fast because it boils down to allocating a block of memory and reading the entire file into it.)

<https://www.sqlite.org/backup.html>