2 ms·
I have experienced this lifecycle many times: 1. Ah, we’re using the database as a queue. 2. Database is running hot, I wonder where all the load is coming fr
by philwelch 6y ago
I have experienced this lifecycle many times:
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.
- pselbert 6y agoIf 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.
- philwelch 6y agoAh, 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.