pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Craig Ringer <craig@postnewspapers.com.au>
To: Merlin Moncure <mmoncure@gmail.com>
Cc: PG-General Mailing List <pgsql-general@postgresql.org>
Subject: Re: Cheapest way to poll for notifications?
Date: Fri, 11 Dec 2009 00:14:39 +0800
Message-ID: <4B211E6F.1070700@postnewspapers.com.au> (raw)
In-Reply-To: <b42b73150912100748r2f3a3fcelb4ea9e43f9e0f0b7@mail.gmail.com>
References: <4B20F639.4070706@postnewspapers.com.au>
	<b42b73150912100748r2f3a3fcelb4ea9e43f9e0f0b7@mail.gmail.com>

Merlin Moncure wrote:
> On Thu, Dec 10, 2009 at 8:23 AM, Craig Ringer
> <craig@postnewspapers.com.au> wrote:
>> Hi
>>
>> As Pg doesn't presently support client push for notifications arising from
>> LISTEN/NOTIFY, I'm wondering if anybody here has done any research into the
>> cheapest statement to issue to check for such notifications.
> 
> notifications are sent to the client as soon as they are generated and
> the socket is not otherwise being used.  psql just prints the
> notifcation message following a query because that happens to be a
> convenient place to do it.  The only polling that has to be done (if
> any) is 100% client side.  There is an excellent example (in C) in the
> documentation showing a method of waiting on the connection socket for
> notification events when the connection is not in use by the client.

Aah, that makes sense. So psql is being sent (and buffering) the
notification immediately, and could choose to report it promptly - say
by calling recv(...) on its socket periodically using an alarm signal.
Since it's not important for psql to report notifications immediately
though, it only checks after statements.

Right?

Anyway, thanks for the explanation, it's appreciated.

--
Craig Ringer



view thread (9+ messages)  latest in thread

Message-ID: <4B211E6F.1070700@postnewspapers.com.au>
Permalink:  ../4B211E6F.1070700@postnewspapers.com.au/
Also on:    postgresql.org/message-id/4B211E6F.1070700@postnewspapers.com.au

 · 

reply

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, mmoncure@gmail.com, pgsql-general@postgresql.org
  Subject: Re: Cheapest way to poll for notifications?
  In-Reply-To: <4B211E6F.1070700@postnewspapers.com.au>
  References: <4B20F639.4070706@postnewspapers.com.au> <b42b73150912100748r2f3a3fcelb4ea9e43f9e0f0b7@mail.gmail.com> <4B211E6F.1070700@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