> So the next question is, if a reader is in the middle of an exec
> and has not finalized its statement yet, how would it affect
> another thread that attempts a statement?

Only one thread can enter sqlite3_* function on the same connection at
the same time. So if you are using sqlite3_exec() then readers will be
able to process one query at a time. If you are using sqlite3_step()
then readers will be able to process one row at a time.


Pavel


On Wed, Jan 25, 2012 at 1:43 PM, Erik Fears <str...@strtok.net> wrote:
> OK. So I'd probably give one connection to the writer, and
> then let the readers share a connection.
>
> So the next question is, if a reader is in the middle of an exec
> and has not finalized its statement yet, how would it affect
> another thread that attempts a statement?
>
> Thanks!
> --erik
>
> On Wed, Jan 25, 2012 at 10:34 AM, Pavel Ivanov <paiva...@gmail.com> wrote:
>
>> > For example,
>> > if the writer thread starts a transaction, and one of the reader threads
>> > does a SELECT,
>> > would the SELECT be part of the transaction? Or are transactions
>> per-thread
>> > on a shared connection?
>>
>> All transactions are per-connection. So yes, SELECT will be a part of
>> transaction and you won't be able to commit or rollback the
>> transaction until all SELECT statements are reset or finalized.
>>
>>
>> Pavel
>>
>>
>> On Wed, Jan 25, 2012 at 1:02 PM, Erik Fears <str...@strtok.net> wrote:
>> > Hello,
>> >
>> > Right now I'm using WAL mode with a single writer, and many readers.
>> >
>> > At the moment, each reader is opening its own database connection.
>> > As you can imagine, this is quite expensive.
>> >
>> > Instead of maintaining a pool of sqlite connections, I'd like to move
>> every
>> > thread to share the same connection.
>> >
>> > The one thing I can't figure out from documentation on sqlite.org is
>> > whether
>> > or not transactions are shared on the same database connection. For
>> > example,
>> > if the writer thread starts a transaction, and one of the reader threads
>> > does a SELECT,
>> > would the SELECT be part of the transaction? Or are transactions
>> per-thread
>> > on
>> > a shared connection?
>> >
>> > Thanks!
>> > Erik
>> > _______________________________________________
>> > sqlite-users mailing list
>> > sqlite-users@sqlite.org
>> > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>> _______________________________________________
>> sqlite-users mailing list
>> sqlite-users@sqlite.org
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to