Priyanka R.
HomeUsesTalksBlogContact
HomeUsesTalks
All posts

Jul 29, 2026 · 1 min read

SKIP LOCKED is a perfectly good queue

Before you add a message broker for background jobs, try the database you already run.

Every team I have joined has, at some point, wanted to add a queue. Usually a whole new system with its own cluster and its own on-call pain. Often the jobs are a few thousand a minute.

Postgres can do this. The trick is SELECT ... FOR UPDATE SKIP LOCKED: each worker grabs a row nobody else is holding and ignores the rest. No double processing, no central coordinator.

The shape we use

  • A jobs table with status, run_at, attempts and a payload column.

  • Workers in Go that loop: pick up to 50 due jobs with SKIP LOCKED, process, mark done in the same transaction.

  • A partial index on (run_at) where status is pending, so the pick query stays fast as done jobs pile up.

  • A nightly job that deletes done rows older than a week. Yes, a job that cleans up jobs.

When it is not enough

If you need fan-out to many consumers, strict ordering across a huge stream, or hundreds of thousands of messages a second, use a real broker. We do, for the warehouse scan events.

© 2026 Priyanka R. · Built on a Sunday. Written in Berlin.

priyanka.raghunathan@example.com

Blog
Contact

But for "send this email", "rebuild this report", "retry this webhook", the database is already there, already backed up, and already monitored. One less thing is a feature.

I gave a version of this as a talk at the Go meetup last year. The most common question afterwards was "but does it scale?" Ours handles about 4,000 jobs a minute on a database that is mostly doing other things. That is enough for most of us.

  • postgres
  • go
  • queues

Keep reading

  • Oct 14, 2026 · 1 min read

    The migration that ran halfway

    We ran a schema migration on a Friday. It stopped at 61%. Here is what I check now before anything touches a big table.

  • Mar 6, 2026 · 1 min read

    Seven years of job interviews from both sides

    I have been interviewed about forty times and have interviewed maybe two hundred people. Some notes, not advice.