diff options
author | Thomas Munro <tmunro@postgresql.org> | 2018-11-28 11:42:32 +1300 |
---|---|---|
committer | Thomas Munro <tmunro@postgresql.org> | 2018-11-28 11:58:10 +1300 |
commit | d67dae036bd71afd2be7a2fafd7bc1ef38bfcdd1 (patch) | |
tree | 51ee94a5a4a611c99ea1bab58223fec2223a6a74 /src | |
parent | 471a7af585b123a8c00416eabbec927f6701583d (diff) | |
download | postgresql-d67dae036bd71afd2be7a2fafd7bc1ef38bfcdd1.tar.gz postgresql-d67dae036bd71afd2be7a2fafd7bc1ef38bfcdd1.zip |
Don't count zero-filled buffers as 'read' in EXPLAIN.
If you extend a relation, it should count as a block written, not
read (we write a zero-filled block). If you ask for a zero-filled
buffer, it shouldn't be counted as read or written.
Later we might consider counting zero-filled buffers with a separate
counter, if they become more common due to future work.
Author: Thomas Munro
Reviewed-by: Haribabu Kommi, Kyotaro Horiguchi, David Rowley
Discussion: https://postgr.es/m/CAEepm%3D3JytB3KPpvSwXzkY%2Bdwc5zC8P8Lk7Nedkoci81_0E9rA%40mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/storage/buffer/bufmgr.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index 01eabe57063..9817770affc 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -733,7 +733,10 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum, bufHdr = LocalBufferAlloc(smgr, forkNum, blockNum, &found); if (found) pgBufferUsage.local_blks_hit++; - else + else if (isExtend) + pgBufferUsage.local_blks_written++; + else if (mode == RBM_NORMAL || mode == RBM_NORMAL_NO_LOG || + mode == RBM_ZERO_ON_ERROR) pgBufferUsage.local_blks_read++; } else @@ -746,7 +749,10 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum, strategy, &found); if (found) pgBufferUsage.shared_blks_hit++; - else + else if (isExtend) + pgBufferUsage.shared_blks_written++; + else if (mode == RBM_NORMAL || mode == RBM_NORMAL_NO_LOG || + mode == RBM_ZERO_ON_ERROR) pgBufferUsage.shared_blks_read++; } |