Determine if a PostgreSQL query was being run from disk or from the memory cache?

Is there a way in the psg client of the Postgres command line command to determine if the request is being executed from disk or from the memory cache?

+4
source share
1 answer

The request is never launched "from disk" or "from cache". The request itself is always in memory.

But if you want to find out if the data was received from shared buffers or directly from the file system, you can use

explain (analyze on, buffers on, verbose on) select .... 

the execution plan will then show you how many blocks are selected from the shared buffers and how many from the file system. Note that β€œreading” from the file system can actually be returned from the cache, and the file system also controls its own cache (something uses Postgres).

+6
source

All Articles