# Radim Marek: How TABLESAMPLE picks rows

> **Key Architectural Takeaway:** Most exploratory questions against a large table only need a rough answer, but without an index on status , even "roughly how many shipped orders" costs a full scan.

**Published:** 2026-10-11T18:45:40+00:00  
**Source:** Planet PostgreSQL  
**Category:** databases-storage  
**Canonical URL:** https://fosswire.org/news/radim-marek-how-tablesample-picks-rows.html  

## Executive Summary
Most exploratory questions against a large table only need a rough answer, but without an index on status , even "roughly how many shipped orders" costs a full scan. On the two-million-row orders table, Postgres has to read every single 8 kB page, all 18,085 of them (141 MB), just to count matching rows. EXPLAIN (ANALYZE, BUFFERS) SELECT count ( * ) FROM orders WHERE status = 'shipped' ; Aggregate Buffers: shared hit=18085 -> Seq Scan on orders (actual rows=500000.00 loops=1) Filter: (status = 'shipped'::text) Rows Removed by Filter: 1500000 Execution Time: 56.188 ms shared hit=18085 is one buffer access per page, every page found already in memory ( Reading Buffer...

## Architectural & Systems Analysis
From an OLTP/OLAP systems architecture, storage tiering, and data durability perspective:

- **Zero-Vendor Lock-in Formats:** Leveraging open specifications (e.g. Parquet, Iceberg) ensures multi-engine interoperability without ingestion lock-in.
- **Vector & In-Memory Throughput:** Modern memory layouts and SIMD-accelerated execution pipelines minimize latency in real-time retrieval.
- **Distributed Resiliency:** Decoupled storage and compute layers enable elastic horizontal scaling with strict ACID guarantees.

## Impact on the Open Ecosystem
Empowers data engineers with open, self-hosted alternatives to monopolistic cloud database providers.
