pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedConnecting to NOTIFY with telnet
9+ messages / 4 participants
[nested] [flat]
* Connecting to NOTIFY with telnet
@ 2019-05-03 18:06 Igal Sapir <igal@lucee.org>
0 siblings, 1 reply; 9+ messages in thread
From: Igal Sapir @ 2019-05-03 18:06 UTC (permalink / raw)
To: pgsql-general
Is it possible to connect to Postgres for notifications via telnet? This
is obviously more for learning/experimenting purposes.
I expected a simple way to connect and consume notifications but can not
find any example or documentation on how to do that.
Any ideas?
Thanks,
Igal
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Connecting to NOTIFY with telnet
@ 2019-05-03 20:09 Andres Freund <andres@anarazel.de>
parent: Igal Sapir <igal@lucee.org>
0 siblings, 1 reply; 9+ messages in thread
From: Andres Freund @ 2019-05-03 20:09 UTC (permalink / raw)
To: Igal Sapir <igal@lucee.org>; +Cc: pgsql-general
Hi,
On 2019-05-03 11:06:09 -0700, Igal Sapir wrote:
> Is it possible to connect to Postgres for notifications via telnet? This
> is obviously more for learning/experimenting purposes.
No. The protocol is too complicated to make that realistically doable /
useful.
> I expected a simple way to connect and consume notifications but can not
> find any example or documentation on how to do that.
If you really wanted to go down that road, you'd have to read the
protocol specs. It'd not make sense to document how-to steps for
something as low-level as this.
Greetings,
Andres Freund
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Connecting to NOTIFY with telnet
@ 2019-05-04 17:35 Igal Sapir <igal@lucee.org>
parent: Andres Freund <andres@anarazel.de>
0 siblings, 1 reply; 9+ messages in thread
From: Igal Sapir @ 2019-05-04 17:35 UTC (permalink / raw)
To: pgsql-general
Thank you both (Michel replied off-list it seems),
On Fri, May 3, 2019 at 1:10 PM Andres Freund <andres@anarazel.de> wrote:
> Hi,
>
> On 2019-05-03 11:06:09 -0700, Igal Sapir wrote:
> > Is it possible to connect to Postgres for notifications via telnet? This
> > is obviously more for learning/experimenting purposes.
>
> No. The protocol is too complicated to make that realistically doable /
> useful.
>
> > I expected a simple way to connect and consume notifications but can not
> > find any example or documentation on how to do that.
>
> If you really wanted to go down that road, you'd have to read the
> protocol specs. It'd not make sense to document how-to steps for
> something as low-level as this.
>
My main "issue" is that the official pgjdbc driver does not support the
notifications with listen and I was trying to figure out why.
I know that the pgjdbc-ng [1] driver does support that feature, but I'm not
sure how many people use it etc. It looks like it's being maintained with
a recent release from a couple of months ago so that's good.
I thought that given the fact that it's just a socket connection it might
be fairly simple to open a connection and listen.
Best,
Igal
[1] http://impossibl.github.io/pgjdbc-ng/
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Connecting to NOTIFY with telnet
@ 2019-05-04 17:43 Christoph Moench-Tegeder <cmt@burggraben.net>
parent: Igal Sapir <igal@lucee.org>
0 siblings, 1 reply; 9+ messages in thread
From: Christoph Moench-Tegeder @ 2019-05-04 17:43 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
## Igal Sapir (igal@lucee.org):
> My main "issue" is that the official pgjdbc driver does not support the
> notifications with listen and I was trying to figure out why.
https://jdbc.postgresql.org/documentation/head/listennotify.html
Regards,
Christoph
--
Spare Space
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Connecting to NOTIFY with telnet
@ 2019-05-04 17:49 Igal Sapir <igal@lucee.org>
parent: Christoph Moench-Tegeder <cmt@burggraben.net>
0 siblings, 1 reply; 9+ messages in thread
From: Igal Sapir @ 2019-05-04 17:49 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Christoph,
On Sat, May 4, 2019 at 10:44 AM Christoph Moench-Tegeder <cmt@burggraben.net>
wrote:
> ## Igal Sapir (igal@lucee.org):
>
> > My main "issue" is that the official pgjdbc driver does not support the
> > notifications with listen and I was trying to figure out why.
>
> https://jdbc.postgresql.org/documentation/head/listennotify.html
>
>
I should have been more explicit. My main issue is with the following
statement from the link that you posted:
> 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
Polling is much less efficient than event handling and I'm sure that
there's a major performance hit with that.
Thanks,
Igal
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Connecting to NOTIFY with telnet
@ 2019-05-04 18:34 Jeff Janes <jeff.janes@gmail.com>
parent: Igal Sapir <igal@lucee.org>
0 siblings, 1 reply; 9+ messages in thread
From: Jeff Janes @ 2019-05-04 18:34 UTC (permalink / raw)
To: Igal Sapir <igal@lucee.org>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>
On Sat, May 4, 2019 at 1:49 PM Igal Sapir <igal@lucee.org> wrote:
> Christoph,
>
> On Sat, May 4, 2019 at 10:44 AM Christoph Moench-Tegeder <
> cmt@burggraben.net> wrote:
>
>> ## Igal Sapir (igal@lucee.org):
>>
>> > My main "issue" is that the official pgjdbc driver does not support the
>> > notifications with listen and I was trying to figure out why.
>>
>> https://jdbc.postgresql.org/documentation/head/listennotify.html
>>
>>
> I should have been more explicit. My main issue is with the following
> statement from the link that you posted:
>
> > 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
>
> Polling is much less efficient than event handling and I'm sure that
> there's a major performance hit with that.
>
Isn't that addressed here?:
// If this thread is the only one that uses the connection,
a timeout can be used to
// receive notifications immediately:
// org.postgresql.PGNotification notifications[] =
pgconn.getNotifications(10000);
Cheers,
Jeff
>
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Connecting to NOTIFY with telnet
@ 2019-05-04 19:03 Igal Sapir <igal@lucee.org>
parent: Jeff Janes <jeff.janes@gmail.com>
0 siblings, 1 reply; 9+ messages in thread
From: Igal Sapir @ 2019-05-04 19:03 UTC (permalink / raw)
To: Jeff Janes <jeff.janes@gmail.com>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Jeff,
On Sat, May 4, 2019 at 11:34 AM Jeff Janes <jeff.janes@gmail.com> wrote:
> On Sat, May 4, 2019 at 1:49 PM Igal Sapir <igal@lucee.org> wrote:
>
>> Christoph,
>>
>> On Sat, May 4, 2019 at 10:44 AM Christoph Moench-Tegeder <
>> cmt@burggraben.net> wrote:
>>
>>> ## Igal Sapir (igal@lucee.org):
>>>
>>> > My main "issue" is that the official pgjdbc driver does not support the
>>> > notifications with listen and I was trying to figure out why.
>>>
>>> https://jdbc.postgresql.org/documentation/head/listennotify.html
>>>
>>>
>> I should have been more explicit. My main issue is with the following
>> statement from the link that you posted:
>>
>> > 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
>>
>> Polling is much less efficient than event handling and I'm sure that
>> there's a major performance hit with that.
>>
>
> Isn't that addressed here?:
>
> // If this thread is the only one that uses the
> connection, a timeout can be used to
> // receive notifications immediately:
> // org.postgresql.PGNotification notifications[] =
> pgconn.getNotifications(10000);
>
>
It "helps", but it's still not the same as keeping the connection open and
receiving messages in real time.
Looking at the documentation of pgjdbc-ng [1] it looks quite impressive.
I'm thinking to try it out and possibly even try to benchmark it for
performance against the official JDBC driver.
Igal
[1]
http://impossibl.github.io/pgjdbc-ng/docs/current/user-guide/#extensions-notifications
> Cheers,
>
> Jeff
>
>>
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Connecting to NOTIFY with telnet
@ 2019-05-04 21:09 Jeff Janes <jeff.janes@gmail.com>
parent: Igal Sapir <igal@lucee.org>
0 siblings, 1 reply; 9+ messages in thread
From: Jeff Janes @ 2019-05-04 21:09 UTC (permalink / raw)
To: Igal Sapir <igal@lucee.org>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>
On Sat, May 4, 2019 at 3:04 PM Igal Sapir <igal@lucee.org> wrote:
> Jeff,
>
> On Sat, May 4, 2019 at 11:34 AM Jeff Janes <jeff.janes@gmail.com> wrote:
>
>> On Sat, May 4, 2019 at 1:49 PM Igal Sapir <igal@lucee.org> wrote:
>>
>>> Christoph,
>>>
>>> On Sat, May 4, 2019 at 10:44 AM Christoph Moench-Tegeder <
>>> cmt@burggraben.net> wrote:
>>>
>>>> ## Igal Sapir (igal@lucee.org):
>>>>
>>>> > My main "issue" is that the official pgjdbc driver does not support
>>>> the
>>>> > notifications with listen and I was trying to figure out why.
>>>>
>>>> https://jdbc.postgresql.org/documentation/head/listennotify.html
>>>>
>>>>
>>> I should have been more explicit. My main issue is with the following
>>> statement from the link that you posted:
>>>
>>> > 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
>>>
>>> Polling is much less efficient than event handling and I'm sure that
>>> there's a major performance hit with that.
>>>
>>
>> Isn't that addressed here?:
>>
>> // If this thread is the only one that uses the
>> connection, a timeout can be used to
>> // receive notifications immediately:
>> // org.postgresql.PGNotification notifications[] =
>> pgconn.getNotifications(10000);
>>
>>
> It "helps", but it's still not the same as keeping the connection open and
> receiving messages in real time.
>
But it is the same as that. It keeps the connection open, and receives the
messages in real time. It blocks either until it gets a NOTIFY, or for 10
seconds, whichever occurs first. You can use 0 to block forever until a
NOTIFY arrives. Maybe you didn't remove the sleep a few lines further
down? Or is there some other problem here?
Cheers,
Jeff
>
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Connecting to NOTIFY with telnet
@ 2019-05-05 03:05 Igal Sapir <igal@lucee.org>
parent: Jeff Janes <jeff.janes@gmail.com>
0 siblings, 0 replies; 9+ messages in thread
From: Igal Sapir @ 2019-05-05 03:05 UTC (permalink / raw)
To: Jeff Janes <jeff.janes@gmail.com>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Jeff,
On Sat, May 4, 2019 at 2:10 PM Jeff Janes <jeff.janes@gmail.com> wrote:
> On Sat, May 4, 2019 at 3:04 PM Igal Sapir <igal@lucee.org> wrote:
>
>> Jeff,
>>
>> On Sat, May 4, 2019 at 11:34 AM Jeff Janes <jeff.janes@gmail.com> wrote:
>>
>>> On Sat, May 4, 2019 at 1:49 PM Igal Sapir <igal@lucee.org> wrote:
>>>
>>>>
>>>> <snip/>
>>>>
>>>> > 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
>>>>
>>>> Polling is much less efficient than event handling and I'm sure that
>>>> there's a major performance hit with that.
>>>>
>>>
>>> Isn't that addressed here?:
>>>
>>> // If this thread is the only one that uses the
>>> connection, a timeout can be used to
>>> // receive notifications immediately:
>>> // org.postgresql.PGNotification notifications[] =
>>> pgconn.getNotifications(10000);
>>>
>>>
>> It "helps", but it's still not the same as keeping the connection open
>> and receiving messages in real time.
>>
>
> But it is the same as that. It keeps the connection open, and receives
> the messages in real time. It blocks either until it gets a NOTIFY, or for
> 10 seconds, whichever occurs first. You can use 0 to block forever until a
> NOTIFY arrives. Maybe you didn't remove the sleep a few lines further
> down? Or is there some other problem here?
>
I didn't try it out, but I know from experience with other systems that
long polling is not as efficient as asynchronous events over an open
socket. For example, Comet vs. WebSockets in web servers.
The only way to find out how big, or small, the impact is, is to benchmark
both implementations, but I have no doubt that the open socket will be more
efficient.
Best,
Igal
^ permalink raw reply [nested|flat] 9+ messages in thread
end of thread, other threads:[~2019-05-05 03:05 UTC | newest]
Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-05-03 18:06 Connecting to NOTIFY with telnet Igal Sapir <igal@lucee.org>
2019-05-03 20:09 ` Andres Freund <andres@anarazel.de>
2019-05-04 17:35 ` Igal Sapir <igal@lucee.org>
2019-05-04 17:43 ` Christoph Moench-Tegeder <cmt@burggraben.net>
2019-05-04 17:49 ` Igal Sapir <igal@lucee.org>
2019-05-04 18:34 ` Jeff Janes <jeff.janes@gmail.com>
2019-05-04 19:03 ` Igal Sapir <igal@lucee.org>
2019-05-04 21:09 ` Jeff Janes <jeff.janes@gmail.com>
2019-05-05 03:05 ` Igal Sapir <igal@lucee.org>
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