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 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 ...