Warda Bibi lays out four classes of scan in PostgreSQL:
To understand how PostgreSQL scans data, we first need to understand how PostgreSQL stores it.
- A table is stored as a collection of 8KB pages (by default) on disk.
- Each page has a header, an array of item pointers (also called line pointers), and the actual tuple data growing from the bottom up.
- Each tuple has its own header containing visibility info: xmin, xmax, cmin/cmax, and infomask bits.
There are different ways PostgreSQL can read data from disk. Depending on the query and available indexes, it can choose from several scan strategies:
- Sequential ScanĀ
- Index Scan
- Index-Only Scan
- Bitmap Index Scan
Read on for a description of those types, as well as when it makes sense for the database engine to select a particular scan type.