On Wed, May 23, 2012 at 1:05 PM, Igor Tandetnik <itandet...@mvps.org> wrote:
> On 5/23/2012 1:51 PM, Sander Jansen wrote:
>>
>> I was always under the impression that prepared statements can only be
>> used from one thread at a time, so if 2 threads need to perform the
>> same query independently, you need to have a prepared statement for
>> each thread. Now I came across the following which seems to contradict
>> this:
>>
>> "
>> http://www.sqlite.org/c3ref/c_config_getmalloc.html#sqliteconfigserialized
>
>
> There is no contradiction. Basically, there's a mutex associated with a
> connection, and sqlite3_step as well as other API functions acquire it on
> entry and release it on exit. So, while it is safe to call sqlite3_step on
> the same statement from multiple threads, it is rather pointless, since a)
> all these calls are going to be serialized on the mutex so you won't
> actually get any parallelism out of this, and b) the statement is traversing
> the same single resultset, so each thread will see some random subset of the
> rows, depending on how their calls happen to interleave.

Ah ok. so for 2 different result sets you need 2 statements. Thanks!
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to