# Row Locks With Joins Can Produce Surprising Results in PostgreSQL

DevFeed: [Row Locks With Joins Can Produce Surprising Results in PostgreSQL](<https://devfeed.tech/articles/row-locks-with-joins-can-produce-surprising-results-in-postgresql-33920.md>)

Original publisher: [Read original article](<https://hakibenita.com/postgres-row-lock-with-join>)

Author: Haki Benita

Published: 2026-02-23T22:00:00Z

Content type: tutorial

Language: en

Sources: [Haki Benita](<https://devfeed.tech/sources/haki-benita.md>)

Topics: [PostgreSQL](<https://devfeed.tech/topics/postgresql.md>), [Concurrency](<https://devfeed.tech/topics/concurrency.md>), [Databases](<https://devfeed.tech/topics/databases.md>), [Query (disambiguation)](<https://devfeed.tech/topics/query.md>)

Tags: [articles](<https://devfeed.tech/tags/articles.md>), [concurrency](<https://devfeed.tech/tags/concurrency.md>), [database](<https://devfeed.tech/tags/database.md>), [locks](<https://devfeed.tech/tags/locks.md>), [postgresql](<https://devfeed.tech/tags/postgresql.md>), [query](<https://devfeed.tech/tags/query.md>), [sql](<https://devfeed.tech/tags/sql.md>)

## AI overview

This article explains a PostgreSQL edge case in which row locks used with joins can produce surprising results, including a query returning no rows despite a valid, enforced foreign key. It uses a concurrent car-ownership update scenario and suggests ways to prevent the issue.

## Source excerpt

You execute a query that joins two tables with a valid an enforces foreign key and it returns no results. How is it possible? We thought it wasn't possible, but a recent incident revealed an edge case we never thought about. In this article I show how under some circumstances row locks with joins can produce surprising results, and suggest ways to prevent it.