]> granicus.if.org Git - postgresql/commitdiff
In ReadOrZeroBuffer (and related entry points), don't bother to call
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 5 Aug 2008 15:09:04 +0000 (15:09 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 5 Aug 2008 15:09:04 +0000 (15:09 +0000)
PageHeaderIsValid when we zero the buffer instead of reading the page in.
The actual performance improvement is probably marginal since this function
isn't very heavily used, but a cycle saved is a cycle earned.

Zdenek Kotala

src/backend/storage/buffer/bufmgr.c

index e40a815b5dd1e70f260c01441a6037ca5876099a..456dc4233604e7f49e13b0c532f02c10c27ea8c4 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.235 2008/08/01 13:16:08 alvherre Exp $
+ *       $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.236 2008/08/05 15:09:04 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -352,28 +352,31 @@ ReadBuffer_common(SMgrRelation smgr, bool isLocalBuf, BlockNumber blockNum,
                if (zeroPage)
                        MemSet((char *) bufBlock, 0, BLCKSZ);
                else
-                       smgrread(smgr, blockNum, (char *) bufBlock);
-               /* check for garbage data */
-               if (!PageHeaderIsValid((PageHeader) bufBlock))
                {
-                       if (zero_damaged_pages)
+                       smgrread(smgr, blockNum, (char *) bufBlock);
+
+                       /* check for garbage data */
+                       if (!PageHeaderIsValid((PageHeader) bufBlock))
                        {
-                               ereport(WARNING,
-                                               (errcode(ERRCODE_DATA_CORRUPTED),
-                                                errmsg("invalid page header in block %u of relation %u/%u/%u; zeroing out page",
-                                                               blockNum, 
-                                                               smgr->smgr_rnode.spcNode,
-                                                               smgr->smgr_rnode.dbNode,
-                                                               smgr->smgr_rnode.relNode)));
-                               MemSet((char *) bufBlock, 0, BLCKSZ);
+                               if (zero_damaged_pages)
+                               {
+                                       ereport(WARNING,
+                                                       (errcode(ERRCODE_DATA_CORRUPTED),
+                                                        errmsg("invalid page header in block %u of relation %u/%u/%u; zeroing out page",
+                                                                       blockNum, 
+                                                                       smgr->smgr_rnode.spcNode,
+                                                                       smgr->smgr_rnode.dbNode,
+                                                                       smgr->smgr_rnode.relNode)));
+                                       MemSet((char *) bufBlock, 0, BLCKSZ);
+                               }
+                               else
+                                       ereport(ERROR,
+                                                       (errcode(ERRCODE_DATA_CORRUPTED),
+                                                        errmsg("invalid page header in block %u of relation %u/%u/%u",
+                                                                       blockNum, smgr->smgr_rnode.spcNode,
+                                                                       smgr->smgr_rnode.dbNode,
+                                                                       smgr->smgr_rnode.relNode)));
                        }
-                       else
-                               ereport(ERROR,
-                                               (errcode(ERRCODE_DATA_CORRUPTED),
-                                errmsg("invalid page header in block %u of relation %u/%u/%u",
-                                               blockNum, smgr->smgr_rnode.spcNode,
-                                               smgr->smgr_rnode.dbNode,
-                                               smgr->smgr_rnode.relNode)));
                }
        }