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 to PostgreSQL over year later.

Two people mentioned SKIP LOCKED in comments, but it was before it was committed even to git repo. But now, we have, officially released, PostgreSQL version with this mechanism, so let's see what it can do.

3 comments

People may wonder how many TPS PostgreSQL can handle when it’s used as a message queue. Lets consider a case when our working set fits into memory. Here are some benchmark results on a more or less regular server (12 cores, 24 Gb ram, HDD)

I got 104 000 TPS which sometimes drops to 90K TPS (when buffers are synced to disk). Without `synchronous_commit=off` I got 1400 TPS, but I doubt that some message queue that honestly fsync’s every enqueued message will show better results.