5 ms·
Worth noting that Postgres has a pubsub implementation built in: listen/notify. https://www.postgresql.org/docs/current/sql-notify.html https://www.postgresql.
by dfee 3y ago
Worth noting that Postgres has a pubsub implementation built in: listen/notify.
https://www.postgresql.org/docs/current/sql-notify.html https://www.postgresql.org/docs/current/sql-notify.html
- brightball 3y agoOh yea, definitely aware of it. I believe many of the queuing solutions utilize it as well. I've ready a lot of reports (on here) that it comes with several unexpected footguns if you really lean on it though.
- cpursley 3y agoYep, I should add that. One of the libraries in my list (that I maintain) is WalEx: https://github.com/cpursley/walex/issues https://github.com/cpursley/walex/issues It subscribes to the Postgres WAL and let you do the same sort of thing you can do with listen/notify, but without the drawbacks like need for triggers or character limits.
- brightball 3y agoGoing to add this to my research list.
- cpursley 3y agoPing me if you have any questions. Long time fan of your blog.
- brightball 3y agoThat is really cool to hear, thank you. And I should have mentioned it before, but we have an open call for speakers for the Carolina Code Conference. This would make for an interesting talk I think.
- maxbond 3y agoWhat's the drawback to a trigger? I would think that any overhead you recouped by avoiding a trigger would be offset by the overhead of sending the entire WAL to your listener, rather than the minimized subset of events that listener is interested in. (To be clear I do see other downsides to listen/notify and I think WalEx makes a lot of sense, I just don't understand this particular example.)
- cpursley 3y agoYou don’t send the entire WAL, just what you subscribe to - and you can even filter via SQL: https://github.com/cpursley/walex?tab=readme-ov-file#publication https://github.com/cpursley/walex?tab=readme-ov-file#publica...
- cpursley 3y agoThis post describes some of the other issues with listen/notify trigger approach: https://news.ycombinator.com/item?id=36323698 https://news.ycombinator.com/item?id=36323698