zlacker

[return to "Postgres is a great pub/sub and job server (2019)"]
1. osigur+Fh[view] [source] 2021-12-18 00:45:32
>>anonu+(OP)
This seems to come up on HN at least once a year. Sure it can work but LISTEN ties up a connection which limits scalability as connections are limited and expensive. Also, mitigation strategies like PgBouncer cannot be used with this approach (nor can scale out solutions like CitusDB I don't think).

Of course, if scalability is not a concern (or the connection limitations are eventually fixed in postgres - this has improved in 14), this would be a very viable approach.

◧◩
2. javajo+7D[view] [source] 2021-12-18 04:10:46
>>osigur+Fh
>LISTEN ties up a connection

Wait, what?? I can't keep doing things with my connection after I issue a LISTEN? That doesn't seem right! I would assume it would isomorphic to how unix-y bg programs will occasionally write to the console (although I see how this might be hard to deal with at the driver level). Now I will have to go check.

◧◩◪
3. gurjee+CD[view] [source] 2021-12-18 04:15:12
>>javajo+7D
You (the application) can certainly go on to issue other database commands. See the docs [1].

> With the libpq library, the application issues LISTEN as an ordinary SQL command, and then must periodically call the function PQnotifies to find out whether any notification events have been received.

[1]: https://www.postgresql.org/docs/current/sql-listen.html

[go to top]