Re: NOTIFY and pg_notify performance when deduplicating notifications

From: Julien Demoor <julien(at)jdemoor(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Catalin Iacob <iacobcatalin(at)gmail(dot)com>
Subject: Re: NOTIFY and pg_notify performance when deduplicating notifications
Date: 2018-11-19 07:30:00
Message-ID: e2645e73-964e-7cd7-02dd-76657339fd3f@jdemoor.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 10/10/2018 19:42, Catalin Iacob wrote:
> On Tue, Oct 9, 2018 at 2:17 PM <julien(at)jdemoor(dot)com> wrote:
>> I just caught an error in my patch, it's fixed in the attachment. The
>> 'never' and 'maybe' collapse modes were mixed up in one location.
>
> Here's a partial review of this version, did not read the doc part
> very carefully.
>
> First of all, I agree that this is a desirable feature as, for a large
> number of notiifications, the O(n^2) overhead quickly becomes very
> noticeable.
>
> I would expect the collapse mode to be an enum which is created from
> the string early on during parsing and used for the rest of the code.
> Instead the string is used all the way leading to string comparisons
> in the notification dispatcher and to the need of hardcoding special
> strings in various places, including the contrib module.
>
> This comment in the beginning of async.c should also be updated:
> * Duplicate notifications from the same transaction are sent out as one
> * notification only. This is done to save work when for example a trigger
>
> pg_notify_3args duplicates pg_notify, I would expect a helper function
> to be extracted and called from both.
>
> There are braces placed on the same line as the if, for example if
> (strlen(collapse_mode) != 0) { which seems to not be the project's
> style.

Thank you for the review. I've addressed all your points in the attached
patch. The patch was made against release 11.1.

I couldn't find a way to make a good helper function for pg_notify_3args
and pg_notify, I hope my proposed solution is acceptable.

Attachment Content-Type Size
postgres-notify-all-v8.patch text/plain 26.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marina Polyakova 2018-11-19 08:16:10 Re: [HACKERS] WIP Patch: Pgbench Serialization and deadlock errors
Previous Message Kuntal Ghosh 2018-11-19 06:15:23 Re: In-place updates and serializable transactions