### Sample Scan
![[assets/ex_samplescan.png|256]]
### The Explain Trace
```sql
-- Sampling 10% of the animals table using the SYSTEM method
EXPLAIN (ANALYZE, COSTS, BUFFERS, VERBOSE)
SELECT * FROM animals TABLESAMPLE SYSTEM (10);
```
```text
Sample Scan on public.animals (cost=1.00..80.00 rows=2000 width=27) (actual time=1.004..1.083 rows=1768 loops=1)
Output: id, name, species_id, created_at
Sampling: system ('10'::real)
Buffers: shared hit=13
```
---
- **Description**: Scans a random sample of rows.
- **Performance**: High performance; `SYSTEM` sampling is typically much faster than `BERNOULLI` as it samples at the block level rather than the row level.
- **Factors**: Sample percentage, sampling method, and physical page layout.
- **Cost**: `sampling cost * sample size`
![[assets/ex_named_tuplestore_scan.svg|256]]
- **Operates on**: [[Structures/Tuple]]
- **Workloads**:
- [[Workloads/IO/DataFile/DataFileRead|IO: DataFileRead]]
- [[Workloads/IO/DataFile/DataFilePrefetch|IO: DataFilePrefetch]]
- [[Workloads/LWLock/Buffers/BufferContent|LWLock: BufferContent]]