On Mon, Jul 19, 2010 at 2:58 PM, Simon Slavin <slav...@bigfraud.org> wrote:
>
> On 19 Jul 2010, at 3:50pm, Sam Carleton wrote:
>
> > I am using the connection pooling in Apache APR's DBD system.  Currently
> > there are multiple places with in one request that does the following:
> >
> >
> >   - Get a connection to the DB
> >   - Call PRAGMA database_list
> >   - Iterate through the list looking for the second database (there will be
> >   either one or two DB)
> >   - Connection to the second one if it is old (wrong physical file) or not
> >   connected.
> >
> > Is this very expensive?  Is it worth it to do this one time at the very
> > beginning of each request as to not do it multiple times?
>
> There is something wrong with your description.  With each new connection to 
> the database (assuming
> that you mean you're doing something that uses sqlite3_open() you will get no 
> attached database files.

Yea,  the way the Apache Portable Runtime (APR) DBD system works is
that it pools connections.  By default it will start with 4
connections and create more connections up to 20.  When the server
isn't under load, it will cut back down to as few as 8 connections.
These numbers are all configurable, of course.

The whole idea is an Apache module asks the DBD for a connection and
it will return a connection.  If there are multiple calls to get a
connection within on Apache 'request', the same connection is always
returned.  The first time the request acquires a connection, it is not
known if the connection is a new connection which was just created, or
an old one from the pool which has been around a while.

In my case, new or old is of little concern except for the fact that
the old connection will be attached to the second DB, the new one will
not.  So, this is why, upon getting the connection from the APR DBD,
there is a check to see if the second DB is attached yet or not.

The module will make 2 to 5 different requests for a connection within
ONE request, is this a costly exercise where I would be better off
adding a special handler to the very front of the request that comes
before anything else and only doing the check once?  Or is the cost
low enough that with 5 to 50 clients all hitting the server every 1 to
5 seconds will never even phase this system?

Sam
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to