I have a slowness problem when running sqlite3 based application.
I have a small db (500 K on disk, only 10000 rows) and I have a loop that
perform 10000 selections according to
the primary key of a certain table.
for some reason in takes 15-20 seconds to run the loop below.
by experimentation I found that this issue is related to the use of
sqlite3_reset. i.e, by creating a new statement in every loop iteration
without reseting and reusing it I got good performance (took a
second,needless to say that I want to avoid this since it causes mem leaks.)
any idea why sqlite3_reset has such a bad performance impact on my program ?
int main() {
sqlite3 * handle;
sqlite3_stmt * m_entrySelectSnumStmt;
sqlite3_open("entries.db",&handle);
std::ostringstream query;
query << "SELECT * FROM entries where SNUM = ? LIMIT 1;";
sqlite3_prepare_v2(handle, query.str().c_str(),
query.str().length()+1, &m_entrySelectSnumStmt, 0);
for(int i = 0; i < 10000; i ++){
sqlite3_bind_int(m_entrySelectSnumStmt,1,i);
int rc = sqlite3_step(m_entrySelectSnumStmt);
sqlite3_clear_bindings(m_entrySelectSnumStmt);
sqlite3_reset(m_entrySelectSnumStmt);
}
}
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users