4 ms·
A client is supposed to poll the queue for new items (i.e. issue pop requests in a loop), or is there some better event-oriented approach for this (via pg notif
by pulkitsh1234 2y ago
A client is supposed to poll the queue for new items (i.e. issue pop requests in a loop), or is there some better event-oriented approach for this (via pg notify ?)
- biehl 2y agoI've thought about this too. But I can't even tell what would be the good default. At low load events seem nicer, but at high load polling seems necessary?
- chuckhend 2y agopop() or read() in a loop, yes. can read 1 message or many messages at a time. what we do at Tembo in our infrastructure is pause for up to a few seconds if a read() returns no messages. when there are messages, then we read() with no pause in between. when the queues are empty it amounts to less than one query per second. there is not much cost to reading frequently if you use a client side connection pool, or a server side pool like pgbouncer.