Row Width Decides How Many Rows Fit on a Page, and How Many Pages Your Query Reads
Because storage is read a page at a time, the number of pages a query must read is the number of rows it touches divided by how many rows fit on a page. Narrow rows pack tightly, perhaps a hundred to an 8 KB page; wide rows full of long text and spare columns pack loosely, so the same one million rows can cost ten thousand pages or a hundred thousand. This is the concrete reason SELECT * over a wide table is slower than selecting the three columns you need, and the reason a narrow table scans surprisingly fast.
Questions this Concept answers
Why does `SELECT *` over a wide table read more pages than selecting three narrow columns from it?
J
jeremy
Text
toast_tuple_target Tuning: PostgreSQL Heap Page Density
A database reads storage one fixed-size page at a time, normally 8 KB, so the cost of a query is the number of pages it has to pull in, not the number of bytes you asked for. How many rows fit on a p…