The slowness had something to do with the way I was compiling.
I'm new to GCC and on MacOSX.
I was compiling with dmalloc, and gdb for debugging - (-ggdb -DDMALLOC
-DDMALLOC_FUNC_CHECK ) but even when I removed those I experienced the
same issues. Why? Who knows - my test code also used Cutest, and some
other constructs.
So I've separated by benchmarking code from my test code, and ... yup. A
pleasant 1000 reads in the .07 seconds I'd hoped for.
Interestingly the sqlite3_get_table() seems to work fine, although I
have more control with using the suggested prepared statements. So
thanks for suggestions all!
Best,
Jonathan
John Stanton wrote:
> Using the deprecated API get_table is very likely the problem.
>
> Jonathan Hendler wrote:
>> Hi All,
>>
>> I'm writing a C application which runs inside of FastCGI process.
>>
>> The problem is that I am getting poor performance... roughly 1000
>> SELECTs in 20 seconds.
>> It's not an indexing issue (I promise). This is true even when there are
>> only 2 rows. I'm not getting errors.
>>
>> PHP PDO sqlite runs about 10000 equivalent SELECTS on the SAME database
>> in about 2 seconds on my machine.
>>
>> What could I be doing so drastically wrong?
>>
>> I am using these defines to do the execution
>>
>> #define SQLITE_GET_RESULTS \
>> char ** result;\
>> char * err;\
>> int rc, nrows,ncols;\
>> rc = sqlite3_get_table(db,sql,&result,&nrows,&ncols,&err);\
>> if (rc != SQLITE_OK){\
>> if(err != NULL){\
>> printf(" err %i: %s\n%s\n",rc,err,sql);\
>> sqlite3_free(err);\
>> sqlite3_free(sql);\
>> } result = NULL; }
>>
>> #define RESULT_ITERATOR(result,ncols,nrows,i,j) \
>> int i,j;\
>> for(i=0;i< nrows ;i++){\
>> for (j=0;j<ncols;j++){
>>
>> #define SQLITE_RESULT_CLEANUP if (result) { sqlite3_free_table(result);}
>> if (sql) { sqlite3_free(sql);}
>>
>> The SQL is created via sqlite3_vmprintf().
>>
>> I've increased the pragmas for memory, it's a shared cache, thread safe
>> - though tweaking these items has not appeared to affect performance.
>>
>> I can provide more relevant information with some hints about where to
>> start.
>>
>> Thanks in advance.
>>
>> Cheers,
>> Jonathan
>>
>> -----------------------------------------------------------------------------
>>
>> To unsubscribe, send email to [EMAIL PROTECTED]
>> -----------------------------------------------------------------------------
>>
>>
>
>
> -----------------------------------------------------------------------------
>
> To unsubscribe, send email to [EMAIL PROTECTED]
> -----------------------------------------------------------------------------
>
>
>
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------