On Fri, 2007-08-10 at 11:25 +0530, Bharath Booshan L wrote:
> Hello All,
> 
>  I am using SQLite in one my application and I require to retrieve around
> 4-5 sets of information simultaneously. I have opted to run the queries in
> separate threads which seems obvious choice here.
> 
>  However, I came to know from one of the documents in sqlite.org that single
> connection cannot be used simultaneously across threads.
> 
>  So I would like to hear any suggestions regarding the best wary to open &
> manage multiple connections i.e.
> 
> a) Is it efficient to create new connections in separate thread each time
> when the query needs to be executed? ( Here I am worried about the time
> taken to open connection )
> 
> b) Is it efficient to create the number of connections required, in a single
> thread and use it in different threads? ( although a connection will not be
> used simultaneously and this will eliminate the effort to create different
> connections but we need to ensure that a connection is used simultaneously
> in different threads)
> 
> Looking forward to your suggestions,

If you have any choice in the matter, don't use threads. Run all 5 
queries from the same thread. You can either run them sequentially,
or sqlite3_prepare() all 5 and then round-robin calls to sqlite3_step().

Either way, things will be more efficient. For you and the application.
Hey, you asked for suggestions. :)

Dan.




-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to