Richard Hipp <d...@sqlite.org> wrote:

> On 5/26/16, Eric Grange <zar...@gmail.com> wrote:
>>
>> I am looking for the fastest way to insert many rows to a simple table.
>
> (1) Create a prepared statement:  "INSERT INTO xyzzy VALUES(?1,?2,...)"
> (2) Run "BEGIN"
> (3) Loop over each row you want to insert, bind values to the prepared
> statement, then call sqlite3_step() and sqlite3_reset().
> (4) Run "COMMIT"
> (5) Call sqlite3_finalize() on the prepared statement to avoid a memory leak.


Additionally, "PRAGMA synchronous=off;" gives significant
speed up for insertions, if you don't mind a corrupted database
in case of system crash. See:

https://www.sqlite.org/pragma.html#pragma_synchronous

Dominique
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to