Perry Smith <pedzsan@gmail.com> writes:
> I'm curious what the design assumptions of the LISTEN / NOTIFY are. For example, would it work to have a thousand
LISTENchannels open at the same time or would that be abusing the assumptions that were made? In short, I'm trying to
understandif I need a few central LISTEN / NOTIFY channels that then distribute the events out or not.
In the current implementation (since 9.0 IIRC), I don't believe the
total number of channels in use affects the transport mechanism at all.
However, the number that a particular backend is listening on would
affect how fast it can process the messages --- we just run through the
local LISTEN-names list serially for a match to see if an incoming
message is interesting or not. So I'd try to avoid having individual
sessions listening to very large numbers of channels. OTOH, the serial
list scan might still be faster than anything you could easily do in SQL
or plpgsql to sort through messages you were trying to route manually.
regards, tom lane