Radim Marek provides an explanation:
At least Postgres avoids flushing its own cache by reading large tables through a small ring buffer. Nevertheless the disk still perform full read. On a primary server handling production traffic is shared with everything else. When all you need is exploratory confirmation “roughly how many” or “are there any representative samples” reading the whole terabyte is too expensive.
SQL Standard comes with
TABLESAMPLEto help with that. It goes in theFROMclause right after the table name, and the rest of the query runs against the subset of pages it picks.
Read on to learn more.