Don't exaggerate the number of temporary blocks read.
authorRobert Haas <rhaas@postgresql.org>
Tue, 31 Oct 2017 09:24:41 +0000 (14:54 +0530)
committerRobert Haas <rhaas@postgresql.org>
Tue, 31 Oct 2017 09:26:09 +0000 (14:56 +0530)
A read that returns zero bytes (or an error) should not increment
the number of temporary blocks read.

Thomas Munro

Discussion: http://postgr.es/m/CAEepm=21xgihg=WaG+O5MFotEZfN6kFETpfw+RkSnEqNQqGn2Q@mail.gmail.com

src/backend/storage/file/buffile.c

index 4ca0ea4f2a343fc1bdd134a96be556252db5a4ca..de85b6805c2a16399864afb3172cdf16d1c38e27 100644 (file)
@@ -264,7 +264,8 @@ BufFileLoadBuffer(BufFile *file)
    file->offsets[file->curFile] += file->nbytes;
    /* we choose not to advance curOffset here */
 
-   pgBufferUsage.temp_blks_read++;
+   if (file->nbytes > 0)
+       pgBufferUsage.temp_blks_read++;
 }
 
 /*