SQLite Forum

long runtime for sqlite3_prepare_v2
Login
Just did some tests myself to optimize a query I've got, and the fastest method I found was doing multiple inserts at once (90 rows with 2 columns, both bound) and reusing that statement.

Over 50 trials, for plain old inserts, it took about 40% less time (~0.83s down from ~1.38s) to insert ~115k rows. For insert on conflict update statements done with newer data applied on top of the old (in case it's relevant, only about 500 of the rows needed updating), the difference was even larger, with single row inserts taking ~0.87s and 90 row inserts taking ~0.35s.

It definitely varies a lot and it can take a little bit of time to find the best number of rows per execution, but it does produce consistently faster times for me.