pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Craig Ringer <craig@postnewspapers.com.au>
To: PG-General Mailing List <pgsql-general@postgresql.org>
Subject: Cheapest way to poll for notifications?
Date: Thu, 10 Dec 2009 21:23:05 +0800
Message-ID: <4B20F639.4070706@postnewspapers.com.au> (raw)

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.

First: is it worth caring? Or is a `SELECT 1;' every few seconds from a 
small (50-ish) number of clients unlikely to have a detectable effect on 
load?

Does it have any significant costs (considering that each statement 
starts its own transaction) ? Is it worth issuing:

BEGIN ISOLATION LEVEL READ COMMITTED, READ ONLY; SELECT 1; ROLLBACK;

rather than just `SELECT 1' ?

I'll be doing some testing on all of this, of course, but I thought I'd 
ask in case others have looked into this already. I didn't see anything 
much in the archives.



One thing I've noticed is that an invalid statement that fails to parse 
still produces the notifications, though it avoids planning and query 
execution. However, it'll also fill the error log with garbage, so it's 
not exactly desirable. The error paths are probably more expensive than 
just running the SELECT anyway.

I wonder if it'd be useful to have a utility statement (perhaps 'LISTEN' 
without arguments?) that was essentially a no-op that _only_ checked 
notifications. It'd make it easier to see why clients were issuing 
apparently random statements, and could possibly be also excluded from 
statement logging even when other things were logged. Would there be any 
support for the idea of something like that? It might be project #2 for 
me once I get around to posting the array_reverse function, if so.

Also: Is there any practical way Pg can ever support server-to-client 
push for notifications? I assume the reasons why it doesn't at present 
are to do with the protocol and with deadlock/concurrency issues at the 
wire level ... is that so?

--
Craig Ringer



view thread (9+ messages)  latest in thread

Message-ID: <4B20F639.4070706@postnewspapers.com.au>
Permalink:  ../4B20F639.4070706@postnewspapers.com.au/
Also on:    postgresql.org/message-id/4B20F639.4070706@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, pgsql-general@postgresql.org
  Subject: Re: Cheapest way to poll for notifications?
  In-Reply-To: <4B20F639.4070706@postnewspapers.com.au>
  References: <4B20F639.4070706@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