Parameter · Version and Platform Compatibility / Previous PostgreSQL Versions
synchronize_seqscans
Enables synchronized sequential scans.
- Default:
on - Type: bool
- Applies: Session (any user)
In plain words
When two queries read the same large table from start to end at about the same time, the second one can start in the middle, where the first one currently is, and wrap around at the end. Both then read each block once from disk while it is still in cache, instead of each reading the whole table separately. The catch: rows come back in a different order than before.
For DBAs and operators
Applies to sequential scans of tables larger than a quarter of shared_buffers (the same tables that use a small ring buffer instead of filling the cache). Each scan reports its position in shared memory; a new scan starts there and wraps around to finish.
Without an ORDER BY, SQL never guarantees row order, but applications and tests sometimes assume "physical order", and then get rows in a seemingly random order or, with LIMIT but no ORDER BY, different rows each time. Turn this off (per session) only to make such legacy behaviour repeatable; the real fix is ORDER BY.
It saves I/O for concurrent full scans of very large tables (reporting, COPY … TO). Default on, and best left on.
How to change it
Any user can change it for their session with SET.