avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leif Mortenson <l...@silveregg.co.jp>
Subject Re: SELECT 1
Date Tue, 22 Jan 2002 00:59:37 GMT
Danny Angus wrote:

>Hi all,
>tailing MySQL logs whilst running James I found a regular "SELECT 1" being
>run, which I now think is  being used to ping the connection.
>However my question is should it be "pung" (Scottish for "pinged" ;) even
>when queries are being regularly executed?
>
>It also seems to be run only when another query is being run anyway.
>Could someone explain this?
>
The data source validates connections before returning them so that any 
problems with the connection can be discovered before returning the bad 
connection to the user code.  This gives the data source the opportunity 
to close the bad connection and create a new good connection and 
transparently return that to the user code so the user code never breaks.

Unfortunately if you write your code so that a connection is allocated 
and then closed for each query, then the number of DB queries is doubled.

I had written a database pool last year which got around this problem by 
keeping track of the last time the connection was released.  Then the 
ping was only made if that time was greater than 5 seconds.  This made a 
big difference by cutting the pings down to nil when the application is 
heavily loaded.  The thinking is that when the queries are spaced close 
together, the fact that the previous query was successful gives the same 
information as the ping would, so it is not necessary.

What about implementing something like this in Avalon's data sources as 
well?  Drawbacks?

Cheers,
Leif



--
To unsubscribe, e-mail:   <mailto:avalon-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-dev-help@jakarta.apache.org>


Mime
View raw message