If your database based queue is introducing lock contention then it is doing things wrong. Since Postgres 9.6 there is `FOR UPDATE SKIP LOCKED` which completely eliminates the issue.
Ah, cool! It’s fully possible I’ve been doing it wrong, or seen it done wrong, or at least that my experience is colored by older and less capable databases.
1. Ah, we’re using the database as a queue.
2. Database is running hot, I wonder where all the load is coming from?
3. Oh, it’s all the queue tables.
It’s not even a scale/load issue. Even at smaller scales you’re introducing some major lock contention.