Jay A. Kreibich schreef:
> On Sat, Oct 10, 2009 at 07:24:33PM +0200, Ron Arts scratched on the wall:
>
>> I'm afraid the process of
>> constructing SQL queries / parsing them by sqlite, and
>> interpreting the results in my app, multiple times per
>> event will be too slow.
>
> There should be no need to construct and parse queries with each
> interaction. Assuming the queries are fairly well known, you should
> be able to prepare them once and then keep using them over and over.
> This should save a noticeable amount of time.
>
> Make sure you're using the prepare/bind/step/reset/finalize
> interfaces, rather than exec or get_table.
>
> -j
>
Thanks Jay,
I'm expanding my benchmark to test just thaty, but I'm running into a problem.
Here's my code (well part of it):
sqlite3_stmt *stmt;
rc = sqlite3_prepare(db, "select name from company where id = '?'", -1,
&stmt, NULL);
if (rc != SQLITE_OK) {
fprintf(stderr, "sqlite3_prepare SQL error: %d\n", rc);
exit(1);
}
for (i=1; i < count; i++) {
rc = sqlite3_bind_int(stmt, 1, rand()%count);
if (rc != SQLITE_OK ){
fprintf(stderr, "sqlite3_bind_int SQL error: %d\n", rc);
exit(1);
}
while (1) {
rc = sqlite3_step(stmt);
if (rc == SQLITE_DONE) {
sqlite3_reset(stmt);
break;
}
if( rc != SQLITE_ROW){
fprintf(stderr, "sqlite3_step SQL error: %d\n", rc);
exit(1);
}
}
}
sqlite3_finalize(stmt);
The sqlite3_bind_int immediately gives me an RANGE_ERROR (25).
Is there some obvious thing I'm doing wrong?
Thanks,
Ron
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users