# Postgres TABLESAMPLE picks disk addresses, not rows

Original title: Tablesample Picks Rows

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

▲ 6 · by [surprisetalk](<https://news.ycombinator.com/user?id=surprisetalk>) · 💬 0
[original](<https://boringsql.com/posts/tablesample/>) · [HN discussion](<https://news.ycombinator.com/item?id=50194157>)

## Summary

TABLESAMPLE SYSTEM samples 1% of pages, not rows, so results come in physical bundles: on a time-ordered table, min(created_at) was off by up to five hours and averages varied ten times more than BERNOULLI. REPEATABLE fixes the seed but not the data—updates and rewrites move rows, so a pinned sample silently changes. Hashing a primary key instead keeps a stable subset through VACUUM FULL and CLUSTER.

## Key quote

> Everything odd about TABLESAMPLE comes from one fact: it doesn't pick rows, it picks addresses.

---

## Cite

- Page: https://zeli.app/story/50194157
- Date: 2026-10-22
- Source: boringsql.com (https://boringsql.com/posts/tablesample/)
- Hacker News: https://news.ycombinator.com/item?id=50194157

## Other languages

- zh: https://zeli.app/zh/story/50194157 · markdown: https://zeli.app/zh/story/50194157.md
- ja: https://zeli.app/ja/story/50194157 · markdown: https://zeli.app/ja/story/50194157.md
- ko: https://zeli.app/ko/story/50194157 · markdown: https://zeli.app/ko/story/50194157.md
- de: https://zeli.app/de/story/50194157 · markdown: https://zeli.app/de/story/50194157.md
- es: https://zeli.app/es/story/50194157 · markdown: https://zeli.app/es/story/50194157.md
- ru: https://zeli.app/ru/story/50194157 · markdown: https://zeli.app/ru/story/50194157.md
