LISTEN / NOTIFY enhancement request for Postgresql - Mailing list pgsql-hackers

From Sev Zaslavsky
Subject LISTEN / NOTIFY enhancement request for Postgresql
Date
Msg-id 52693FC5.7070507@gmail.com
Whole thread Raw
Responses Re: LISTEN / NOTIFY enhancement request for Postgresql  (Bruce Momjian <bruce@momjian.us>)
List pgsql-hackers
Hi pgsql-hackers,<br /><br /> The LISTEN / NOTIFY feature (along with the pg_notify() function) is a unique feature
thatdifferentiates Postgresql from nearly all other relational database systems.  With the exception of SQL Server, I
knowof no other RDBMSs that allow a client to be asynchronously notified by the database server.<br /><br /> This
featureembodies the modern "push" approach and allows delivering timely data to the user as it changes, instead of the
moretraditional "pull" approach which requires the user to request the data at specific intervals.  Vendors are rolling
out"push" technologies to meet market demand.  Microsoft recently introduced SignalR - which is a framework for pushing
contentto ASP.NET Web pages.  Similarly Complex Event Processing systems "push" information to users' dashboards in
real-time.<br/><br /> In contrast with RDBMS's where asynchronous notification is a special feature, message broker
softwareimplementations live and breathe asynchronous notification.    So I feel that the LISTEN / NOTIFY feature is
tryingto deliver some of the asynchronous notification features of a message broker but it lacks some of the
flexibility.<br/><br /> One particular shortcoming of LISTEN / NOTIFY is the fact that the channel specified on the
LISTENmust <u>exactly </u>match the channel specified on the NOTIFY.  Here is an example of the problem:<br /><br /> I
havetwo listeners:<br />      1. Interested in all stock quote updates<br />      2. Interested in stock quote updates
forIBM only<br /><br /> There is a table that contains stock prices with a trigger proc that issues a NOTIFY using
pg_notify()upon update.  There isn't a single channel that I can use that will deliver the message to both listeners. 
Toget around the problem I could publish a message on channel "PRICE" and another message on channel "PRICE.IBM" but
sendingtwo notifications is far from optimal.<br /><br /> Message brokers have implemented a neat way to get around
thisissue.   It is accomplished by allowing wildcards in message topic subscriptions.<br /><br /> Here is an example
implementation:<aclass="moz-txt-link-freetext" href="http://activemq.apache.org/nms/activemq-wildcards.html">
http://activemq.apache.org/nms/activemq-wildcards.html</a><br/><br /><ul><li> is used to separate names in a
path<li><tt>*</tt>is used to match any name in a path<li><tt>></tt> is used to recursively match any destination
startingfrom this name</ul><p>For example using the example above, these subscriptions are possible<div
class="table-wrap"><tableclass="confluenceTable"><tbody><tr><th class="confluenceTh" colspan="1"
rowspan="1">Subscription</th><thclass="confluenceTh" colspan="1" rowspan="1">Meaning</th></tr><tr><td
class="confluenceTd"colspan="1" rowspan="1"><tt>PRICE.></tt></td><td class="confluenceTd" colspan="1"
rowspan="1">Anyprice for any product on any exchange</td></tr><tr><td class="confluenceTd" colspan="1"
rowspan="1"><tt>PRICE.STOCK.></tt></td><tdclass="confluenceTd" colspan="1" rowspan="1">Any price for a stock on any
exchange</td></tr><tr><tdclass="confluenceTd" colspan="1" rowspan="1"><tt>PRICE.STOCK.NASDAQ.*</tt></td><td
class="confluenceTd"colspan="1" rowspan="1">Any stock price on NASDAQ</td></tr><tr><td class="confluenceTd" colspan="1"
rowspan="1"><tt>PRICE.STOCK.*.IBM</tt></td><tdclass="confluenceTd" colspan="1" rowspan="1">Any IBM stock price on any
exchange</td></tr></tbody></table></div><br/> My request is to implement the same or similar feature in Postgresql.<br
/><br/> Thank you.<br /><br /> -Sev<br /> 

pgsql-hackers by date:

Previous
From: Hugo Mercier
Date:
Subject: Re: Detection of nested function calls
Next
From: Tom Lane
Date:
Subject: Re: Detection of nested function calls