Re: Proposed fix for NOTIFY performance degradation - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Proposed fix for NOTIFY performance degradation
Date
Msg-id 4306.1303587853@sss.pgh.pa.us
Whole thread Raw
In response to Proposed fix for NOTIFY performance degradation  (Gianni Ciolli <gianni.ciolli@2ndquadrant.it>)
Responses Re: Proposed fix for NOTIFY performance degradation  (Simon Riggs <simon@2ndQuadrant.com>)
List pgsql-hackers
Gianni Ciolli <gianni.ciolli@2ndquadrant.it> writes:
> [ proposes lobotomization of duplicate-elimination behavior in NOTIFY ]

I think this change is likely to be penny-wise and pound-foolish.
The reason the duplicate check is in there is that things like triggers
may just do "NOTIFY my_table_changed".  If the trigger is fired N times
in a transaction, and you don't have duplicate-elimination in NOTIFY,
then you get N duplicate messages to no purpose.  And the expense of
actually sending (and processing) those messages is a lot higher than
suppressing them would be.

With the proposed change, the simplest case of just one such trigger is
still covered, but not two or more.  I don't think this is good enough.
It's basically throwing the responsibility on the application programmer
to avoid duplicates --- and in most scenarios, it will cost much more
to suppress duplicates in PL code than to do it here.

When I started to read this patch I was hoping to see some clever scheme
for detecting dups at lower cost than what we currently do, like perhaps
hashing.  I'm not impressed with just abandoning the responsibility,
though.

One idea we might consider is to offer two forms of NOTIFY, one that
suppresses dups and one that doesn't, so that in cases where the app
programmer knows his code doesn't generate (many) dups he can tell us
not to bother checking.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Some TODO items for collations
Next
From: "Mike Pultz"
Date:
Subject: Re: smallserial / serial2