Re: Cheapest way to poll for notifications? & Driver improvement question re SSL and notify

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: Maciek Sakrejda <msakrejda(at)truviso(dot)com>
Cc: PG-JDBC Mailing List <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Cheapest way to poll for notifications? & Driver improvement question re SSL and notify
Date: 2009-12-21 01:36:55
Message-ID: 4B2ED137.50501@postnewspapers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-jdbc

Maciek Sakrejda wrote:

> Does the jdbc driver work with EmptyQueryResponse? At the protocol
> level, if you send a Query message with an all-whitespace sql string,
> the backend is supposed to reply with a single EmptyQueryResponse
> message and then issue ReadyForQuery again. I have a feeling that jdbc
> is probably "too smart" for this to work, but it could be worth a
> shot.

Even if the JDBC driver avoids sending such a query, it'd be a handy
behavior to use if explicit polling was implemented in the driver
interface. Send an empty Query message, read() from the buffer now that
you know there's something in it (the server's empty query response) and
see if there are any async notifications in the buffer before the empty
query response.

Thanks for the tip. If the JDBC folks ever stick their heads up here to
comment on any of this or to respond to the docs patches I've sent them
I'll see if they'd accept a patch for this and put one together if so.
It wouldn't be as efficient as purely client-side polling as it'd
require a network round trip, but it'd be a whole lot simpler and would
avoid spamming the db logs.

--
Craig Ringer

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alex - 2009-12-21 03:28:36 Re: PL/Perl Performance Problems
Previous Message John DeSoi 2009-12-21 01:30:11 Re: Extended Query, flush or sync ?

Browse pgsql-jdbc by date

  From Date Subject
Next Message Andreas Brandl 2009-12-21 02:24:35 Re: keeping Connection alive
Previous Message Maciek Sakrejda 2009-12-21 01:24:39 Re: Cheapest way to poll for notifications? & Driver improvement question re SSL and notify