# PostgreSQL's 16-Slot Lock Fast Path Is a Hidden Bottleneck for Over-Indexed Tables

Original title: Sixteen Locks Ought to Be Enough for Anybody

> Hacker News story 49699611 · language: en · submitted 2026-09-14
> Web version: https://zeli.app/story/49699611
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 13 · by [speckx](<https://news.ycombinator.com/user?id=speckx>) · 💬 4
[original](<https://thebuild.com/blog/sixteen-locks-ought-to-be-enough-for-anybody/>) · [HN discussion](<https://news.ycombinator.com/item?id=49699611>)

## Summary

Every query in PostgreSQL takes an AccessShareLock on every index on a table, even ones it doesn't use. Through version 17, each backend has only 16 fast-path slots for these weak locks; overflow goes through the shared lock table and its 16 LWLocks, causing contention on trivial primary-key lookups. Prepared statements can cut locks from 22 to 2, and PostgreSQL 18 sizes the fast-path array from max_locks_per_transaction, giving 64 slots by default.

## Key quote

> The disease is a table with 21 indexes.

---

## Cite

- Page: https://zeli.app/story/49699611
- Date: 2026-09-14
- Source: thebuild.com (https://thebuild.com/blog/sixteen-locks-ought-to-be-enough-for-anybody/)
- Hacker News: https://news.ycombinator.com/item?id=49699611

## Other languages

- zh: https://zeli.app/zh/story/49699611 · markdown: https://zeli.app/zh/story/49699611.md
- ja: https://zeli.app/ja/story/49699611 · markdown: https://zeli.app/ja/story/49699611.md
- ko: https://zeli.app/ko/story/49699611 · markdown: https://zeli.app/ko/story/49699611.md
