> 1) How "expensive" is a call to sqlite3_open. Does a call to 
> sqlite3_enable_shared_cache make it "cheaper"?

Its cost depends on the size of your schema as it gets parsed during
open. Shared cache doesn't make it cheaper. It can make somewhat
cheaper (in some cases) to use several connections to the same
database with the cost of mutual exclusion of sqlite3_step calls
working with any handle to the same database. But that's it.

> 2) If sqlite3_open is an expensive operation then I would like to keep a list 
> (cache) of open database connections (sqlite*'s). Here's how it *should* 
> work: The main thread calls sqlite3_open a couple of times and pushes the 
> resulting sqlite-handles into a concurrent queue. The worker thread then pops 
> the handle from the queue, does what needs to be done and pushes the handle 
> back. No sqlite-handle is used by more than one thread at the same time. Is 
> that safe?

Yes, that's perfectly safe.


Pavel

On Tue, Nov 30, 2010 at 9:37 AM, Christoph Schreiber <luky0...@yahoo.de> wrote:
> Hi, I'm working on a multi-threaded image server and I have 2 questions:
>
> 1) How "expensive" is a call to sqlite3_open. Does a call to 
> sqlite3_enable_shared_cache make it "cheaper"?
>
> 2) If sqlite3_open is an expensive operation then I would like to keep a list 
> (cache) of open database connections (sqlite*'s). Here's how it *should* 
> work: The main thread calls sqlite3_open a couple of times and pushes the 
> resulting sqlite-handles into a concurrent queue. The worker thread then pops 
> the handle from the queue, does what needs to be done and pushes the handle 
> back. No sqlite-handle is used by more than one thread at the same time. Is 
> that safe?
>
> Cheers, Christoph
>
>
> _______________________________________________
> 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