SQLite Forum

long runtime for sqlite3_prepare_v2
Login
SQLite is optimized for a small number of parameters in each SQL statement.
The usual number in practice is one or two.  SQLite is efficient with dozens.

But the performance is quadratic in the number of parameters, so when you put
in 32768, it slows down.  A lot.  We could refactor the way in which
parameters are processed to make it faster for a huge number of parameters like
this, but that would slow down processing for the common case where the number
of parameters is 1 or 2.

I suggest that you change your application to use just two parameters:

> ~~~~
INSERT INTO keytable(FVIdx,hashkey) VALUES(@J,@KEY);
~~~~

Then run the statement once for each J and KEY value, inside of a transaction.