From: Craig Ringer <craig@postnewspapers.com.au>
To: PG-General Mailing List <pgsql-general@postgresql.org>
Subject: Re: Cheapest way to poll for notifications?
Date: Fri, 11 Dec 2009 23:39:21 +0800
Message-ID: <4B2267A9.1080302@postnewspapers.com.au> (raw)
In-Reply-To: <C746D04C.CAE15%scott_ribe@killerbytes.com>
References: <C746D04C.CAE15%scott_ribe@killerbytes.com>
Scott, Tom, Merlin:
Thanks for the comments and help. It's all sorted now - the origin of
the confusion was some outdated information in the JDBC driver
documentation.
The question arose because I was originally looking at polling from JDBC
(which I know I forgot to mention), where the docs state that:
"A key limitation of the JDBC driver is that it cannot receive
asynchronous notifications and must poll the backend to check if any
notifications were issued."
http://jdbc.postgresql.org/documentation/84/listennotify.html
.... and show a `SELECT 1' being issued to push any notifications.
I'd assumed that was a JDBC limitation until I tested with psql and
found that it, too, required some kind of client-initiated communication
to see NOTIFY events, at which point I began wondering if the backend
pushed them at all rather than waiting for client interaction. Hence my
question.
Anyway, as pointed out, psql just doesn't bother polling for
notifications because it's not important for psql, but it could if it
needed to - the notifications are waiting in its recieve buffer for it
to notice and care.
As for the JDBC driver - it turns out that the documentation is
out-of-date and/or misleading. The JDBC driver *does* support reading
notifications the backend has pushed to its receive buffer, and does
*not* have to poll the backend or issue a statement to receive
notifications. Some searching suggests that this changed in 8.0 or 8.1 .
The documentation needs adjusting, so I've sent a patch to it off to the
JDBC folks.
--
Craig Ringer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: craig@postnewspapers.com.au, pgsql-general@postgresql.org
Subject: Re: Cheapest way to poll for notifications?
In-Reply-To: <4B2267A9.1080302@postnewspapers.com.au>
References: <C746D04C.CAE15%scott_ribe@killerbytes.com> <4B2267A9.1080302@postnewspapers.com.au>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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