Re: Cheapest way to poll for notifications?

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Cheapest way to poll for notifications?
Date: 2009-12-10 16:14:39
Message-ID: 4B211E6F.1070700@postnewspapers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-jdbc

Merlin Moncure wrote:
> On Thu, Dec 10, 2009 at 8:23 AM, Craig Ringer
> <craig(at)postnewspapers(dot)com(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message dipti shah 2009-12-10 16:27:10 Re: Defining permissions for tables, schema etc..
Previous Message Adrian Klaver 2009-12-10 16:13:19 Re: pg_dump and ON DELETE CASCADE problem

Browse pgsql-jdbc by date

  From Date Subject
Next Message Tom Lane 2009-12-10 17:06:36 Re: Cheapest way to poll for notifications?
Previous Message Craig Ringer 2009-12-10 16:10:06 Re: Cheapest way to poll for notifications?