SQLite Forum

Fast way to insert rows in SQLite
Login
Hey, it does help in the case of SQLite. Here is what I did, 

1. Without batching:

    I called `INSERT INTO user VALUES (NULL,?,?,?);` for 100M and the whole thing took 60s:

        59.64 real
        57.01 user
        2.27 sys

    The code is [here](https://github.com/avinassh/fast-sqlite3-inserts/blob/master/src/bin/basic_prep.rs)

2. With batching:

    I batched, did inserts of 50 rows at once, `INSERT INTO user VALUES (NULL,?,?,?) (NULL,?,?,?) x50` in loop of 100M/50, it took 34s:

        34.04 real
        31.66 user
        2.20 sys

    The code is [here](https://github.com/avinassh/fast-sqlite3-inserts/blob/master/src/bin/basic_batched.rs)

I also tried increasing the batch size to 100, it was almost same and at 500 it took more time.