<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/replacing-message-queues-with-for-update-skip-locked-coding-database-programming-rcxptk0po" -->

---
title: Replacing Message Queues with FOR UPDATE SKIP LOCKED...
description: Using PostgreSQL's FOR UPDATE SKIP LOCKED clause lets developers build a concurrent, wait-free job queue directly in a relational database, avoiding the...
canonical: https://daily.dev/posts/replacing-message-queues-with-for-update-skip-locked-coding-database-programming-rcxptk0po
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Replacing Message Queues with FOR UPDATE SKIP LOCKED #coding #database #programming | daily.dev
og:description: Using PostgreSQL's FOR UPDATE SKIP LOCKED clause lets developers build a concurrent, wait-free job queue directly in a relational database, avoiding the...
og:url: https://daily.dev/posts/replacing-message-queues-with-for-update-skip-locked-coding-database-programming-rcxptk0po
og:image: https://api.daily.dev/og/posts/RcxPTk0po.png
og:image:alt: Replacing Message Queues with FOR UPDATE SKIP LOCKED #coding #database #programming
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Replacing Message Queues with FOR UPDATE SKIP LOCKED #coding #database #programming

**[The Coding Gopher](https://daily.dev/sources/codinggopher)** · 1 min read · 0 upvotes · 0 comments

## Summary

Using PostgreSQL's FOR UPDATE SKIP LOCKED clause lets developers build a concurrent, wait-free job queue directly in a relational database, avoiding the operational overhead of provisioning RabbitMQ or Redis solely for task distribution. The clause solves the classic problem of workers contending over the same pending row: instead of blocking on a locked row, a worker simply skips it and grabs the next available one, enabling thousands of jobs per second to be processed concurrently.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=HM-8w7DRyCs>

## Questions this post answers

### How does FOR UPDATE SKIP LOCKED prevent workers from blocking each other in a Postgres job queue?

It changes row locking behavior so that when a worker's query encounters a row already locked by another transaction, it skips that row instead of waiting, then locks and returns the next available unlocked row. This lets multiple workers concurrently pull different pending job rows from the same table without contention, turning a standard table into a wait-free queue capable of thousands of jobs per second.

_Developers weighing Postgres against RabbitMQ or Redis for job queues can track these architecture trade-offs on daily.dev._

### Can I use Postgres instead of RabbitMQ or Redis for a background job queue?

Yes, a standard Postgres table can serve as a highly concurrent, wait-free job queue using the FOR UPDATE SKIP LOCKED clause, avoiding the architectural overhead of provisioning a separate message broker. This approach relies on native Postgres concurrency control rather than external infrastructure, while still supporting high job throughput.

_Anyone deciding between a dedicated broker and a database-backed queue can follow this comparison on daily.dev._

## Similar posts on daily.dev

- [Implementing Durable Workflows on Postgres Without an External Orchestrator](https://daily.dev/posts/implementing-durable-workflows-on-postgres-without-an-external-orchestrator-hn7fsiivi) · InfoQ · 0 upvotes · 0 comments
- [I Tried the “Just Use Postgres” Queue for Six Weeks. SKIP LOCKED Paid Until It Didn’t](https://daily.dev/posts/i-tried-the-just-use-postgres-queue-for-six-weeks-skip-locked-paid-until-it-didn-t-sni9qhs1s) · Medium · 2 upvotes · 0 comments
- [Making Postgres queues scale](https://daily.dev/posts/making-postgres-queues-scale-otqspthk6) · Hacker News · 1 upvotes · 0 comments
- [Building a Reliable PostgreSQL Queue: Concurrency, Crashes, Retries, and Scale – Master.dev Blog](https://daily.dev/posts/building-a-reliable-postgresql-queue-concurrency-crashes-retries-and-scale-master-dev-blog-0yuhzwdif) · Frontend Masters · 1 upvotes · 0 comments

---

Tags: [#architecture](https://daily.dev/tags/architecture), [#postgresql](https://daily.dev/tags/postgresql), [#redis](https://daily.dev/tags/redis)

[View this post on daily.dev](https://daily.dev/posts/replacing-message-queues-with-for-update-skip-locked-coding-database-programming-rcxptk0po)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Replacing Message Queues with FOR UPDATE SKIP LOCKED #coding #database #programming","url":"https://daily.dev/posts/replacing-message-queues-with-for-update-skip-locked-coding-database-programming-rcxptk0po","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/replacing-message-queues-with-for-update-skip-locked-coding-database-programming-rcxptk0po"},"datePublished":"2026-09-22T16:09:00.152Z","dateModified":"2026-09-22T16:09:19.916Z","description":"Using PostgreSQL's FOR UPDATE SKIP LOCKED clause lets developers build a concurrent, wait-free job queue directly in a relational database, avoiding the...","image":"https://i.ytimg.com/vi/HM-8w7DRyCs/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/HM-8w7DRyCs/sddefault.jpg","isAccessibleForFree":true,"articleSection":"The Coding Gopher","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"The Coding Gopher","logo":"https://media.daily.dev/image/upload/s--pv2IKQMG--/f_auto/v1736753456/logos/codinggopher","url":"https://daily.dev/sources/codinggopher"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/replacing-message-queues-with-for-update-skip-locked-coding-database-programming-rcxptk0po","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"architecture,postgresql,redis","timeRequired":"PT1M","video":{"@type":"VideoObject","name":"Replacing Message Queues with FOR UPDATE SKIP LOCKED #coding #database #programming","description":"Using PostgreSQL's FOR UPDATE SKIP LOCKED clause lets developers build a concurrent, wait-free job queue directly in a relational database, avoiding the...","thumbnailUrl":"https://i.ytimg.com/vi/HM-8w7DRyCs/sddefault.jpg","uploadDate":"2026-09-22T16:09:00.152Z","duration":"PT1M","url":"https://api.daily.dev/r/RcxPTk0po","embedUrl":"https://www.youtube.com/embed/HM-8w7DRyCs"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"The Coding Gopher","item":"https://daily.dev/sources/codinggopher"},{"@type":"ListItem","position":3,"name":"Replacing Message Queues with FOR UPDATE SKIP LOCKED #coding #database #programming"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/replacing-message-queues-with-for-update-skip-locked-coding-database-programming-rcxptk0po#faq","mainEntity":[{"@type":"Question","name":"How does FOR UPDATE SKIP LOCKED prevent workers from blocking each other in a Postgres job queue?","acceptedAnswer":{"@type":"Answer","text":"It changes row locking behavior so that when a worker's query encounters a row already locked by another transaction, it skips that row instead of waiting, then locks and returns the next available unlocked row. This lets multiple workers concurrently pull different pending job rows from the same table without contention, turning a standard table into a wait-free queue capable of thousands of jobs per second. Developers weighing Postgres against RabbitMQ or Redis for job queues can track these architecture trade-offs on daily.dev."}},{"@type":"Question","name":"Can I use Postgres instead of RabbitMQ or Redis for a background job queue?","acceptedAnswer":{"@type":"Answer","text":"Yes, a standard Postgres table can serve as a highly concurrent, wait-free job queue using the FOR UPDATE SKIP LOCKED clause, avoiding the architectural overhead of provisioning a separate message broker. This approach relies on native Postgres concurrency control rather than external infrastructure, while still supporting high job throughput. Anyone deciding between a dedicated broker and a database-backed queue can follow this comparison on daily.dev."}}]}
```

