NOTIFY and pg_notify performance when deduplicating notifications

From: <julien(at)jdemoor(dot)com>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: NOTIFY and pg_notify performance when deduplicating notifications
Date: 2018-10-02 17:19:53
Message-ID: 054001d45a74$23960f10$6ac22d30$@jdemoor.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Back in 2016 a patch was proposed to fix the O(N^2) performance on transactions that generate many notifications. The performance issue is caused by the check for duplicate notifications.

I have a feature built around LISTEN / NOTIFY that works perfectly well, except for the enormous performance impact to transactions that emit large numbers of notifications. It’s very hard to work around the problem on the application side and transactions that could take just a few seconds end up taking over 30 minutes.

The patch that was proposed was nearly finalized, but ended up being abandoned. The latest patch is here: https://www.postgresql.org/message-id/CAP_rwwmKjO_p3kYB4jYceqcvcyRYjBQdji1GSCyqvLK%3D5nZzWQ%40mail.gmail.com .

I understand that the only work left to be done on the patch was to address comments made on the proposed syntax. I’m attaching an updated patch that changes the syntax to allow for a variable number of modes. The new syntax would be NOTIFY channel [ , payload [ , collapse_mode ] ] ; where collapse_mode can be 'never' or 'maybe'.

I hope this patch can be reviewed and included in PostgreSQL.

Best regards.

--
Julien Demoor

Attachment Content-Type Size
postgresql-notify-collapse-mode.patch application/octet-stream 14.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-10-02 17:20:58 Re: Cygwin linking rules
Previous Message Tom Lane 2018-10-02 17:07:21 Re: Cygwin linking rules