Some time ago, I wrote blogpost about how to pick a task from queue, without locking. It was written in 2013, and as such it couldn't reflect everything we have now in PostgreSQL - namely SKIP LOCKED - which was added ...

On 17th of July, Robert Haas committed patch: Add new function pg_notification_queue_usage. This tells you what fraction of NOTIFY's queue is currently filled. Brendan Jurd, reviewed by Merlin Moncure and Gurjeet Singh. A few further tweaks by me.

On 7th of October, Alvaro Herrera committed patch: Implement SKIP LOCKED for row-level locks This clause changes the behavior of SELECT locking clauses in the presence of locked rows: instead of causing a process to block waiting for the locks held by other processes ...

There is new blogpost on this subject! There are cases where system stores list of things to do, and then there are some worker processes that check the list, pick something to work on, do it, and remove from the list. Proper ...

Similar question has been asked many times on mailing lists and on IRC. Sometimes it's not mail sending, but file/directory creation, or something else that generally requires some interaction with "world outside of database". Can it be done? Sure. How, then?