Postgresql – Is pg12 cache used with two SELECT on same table but different fields


Figure a table with fields a, b and c

Figure two requests on this table :

SELECT a, b from table

SELECT b, c from table

Is postgres able to reuse cache for the second request?

Best Answer

The cache stores blocks read from from disk. A single block contains one or more rows from a table.

As both queries read the same data, they request the same blocks. So yes, the second query will be reading the blocks from the cache.