pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedFastest way to check aliveness of connection
3+ messages / 2 participants
[nested] [flat]
* Fastest way to check aliveness of connection
@ 2008-02-26 13:36 Daniel Migowski <dmigowski@ikoffice.de>
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Migowski @ 2008-02-26 13:36 UTC (permalink / raw)
To: pgsql-jdbc
Hello,
I want to implement a c3p0 ConnectionTester and now need a fast way to
check for the alivelyness of a Connection. Currently I issue a "select
1" to the database and if I don't get an exception I assume the
connection is still alive.
Is there a faster way? How can I check if the underlying socket is still
alive without doing a JDBC request? This has to work only with
PostgreSQL JDBC, so I can cast to any postgres interface available.
With best regards,
Daniel Migowski
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Fastest way to check aliveness of connection
@ 2008-02-26 22:20 Oliver Jowett <oliver@opencloud.com>
parent: Daniel Migowski <dmigowski@ikoffice.de>
0 siblings, 1 reply; 3+ messages in thread
From: Oliver Jowett @ 2008-02-26 22:20 UTC (permalink / raw)
To: Daniel Migowski <dmigowski@ikoffice.de>; +Cc: pgsql-jdbc
Daniel Migowski wrote:
> Hello,
>
> I want to implement a c3p0 ConnectionTester and now need a fast way to
> check for the alivelyness of a Connection. Currently I issue a "select
> 1" to the database and if I don't get an exception I assume the
> connection is still alive.
>
> Is there a faster way? How can I check if the underlying socket is still
> alive without doing a JDBC request? This has to work only with
> PostgreSQL JDBC, so I can cast to any postgres interface available.
Running an empty query ("") is probably the simplest way.
In theory you could do something slightly faster at the protocol level
(just send Sync and wait for ReadyForQuery) but there's no interface
currently exposed to do that and I doubt that it will be much faster
than an empty query anyway.
-O
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Fastest way to check aliveness of connection
@ 2008-02-27 07:57 Daniel Migowski <dmigowski@ikoffice.de>
parent: Oliver Jowett <oliver@opencloud.com>
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Migowski @ 2008-02-27 07:57 UTC (permalink / raw)
To: Oliver Jowett <oliver@opencloud.com>; +Cc: pgsql-jdbc
Hello Oliver,
Oliver Jowett schrieb:
> Running an empty query ("") is probably the simplest way.
>
> In theory you could do something slightly faster at the protocol level
> (just send Sync and wait for ReadyForQuery) but there's no interface
> currently exposed to do that and I doubt that it will be much faster
> than an empty query anyway.
Yes, I investigated that, but since the normal query procedure also just
sends one package, the gain for just sending the sync does not really
matter. Of course, your idea with the empty query is great. Thanks alot.
With best regards,
Daniel Migowski
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2008-02-27 07:57 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-02-26 13:36 Fastest way to check aliveness of connection Daniel Migowski <dmigowski@ikoffice.de>
2008-02-26 22:20 ` Oliver Jowett <oliver@opencloud.com>
2008-02-27 07:57 ` Daniel Migowski <dmigowski@ikoffice.de>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox