Re: Connecting to NOTIFY with telnet

Поиск
Список
Период
Сортировка
От Igal Sapir
Тема Re: Connecting to NOTIFY with telnet
Дата
Msg-id CA+zig08GF9W8Dc1kKZ=u4E=XTgS92Cvjt9qj7w_sUi+5L_sQkw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Connecting to NOTIFY with telnet  (Jeff Janes <jeff.janes@gmail.com>)
Список pgsql-general
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
 

В списке pgsql-general по дате отправления:

Предыдущее
От: Jeff Janes
Дата:
Сообщение: Re: Connecting to NOTIFY with telnet
Следующее
От: Sathish Kumar
Дата:
Сообщение: Import Database