1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Remove unnecessary calls of FlushRelationBuffers: there is no need

to write out data that we are about to tell the filesystem to drop.
smgr_internal_unlink already had a DropRelFileNodeBuffers call to
get rid of dead buffers without a write after it's no longer possible
to roll back the deleting transaction.  Adding a similar call in
smgrtruncate simplifies callers and makes the overall division of
labor clearer.  This patch removes the former behavior that VACUUM
would write all dirty buffers of a relation unconditionally.
This commit is contained in:
Tom Lane
2005-03-20 22:00:54 +00:00
parent 683f60da3d
commit 354049c709
10 changed files with 91 additions and 236 deletions

View File

@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/smgr/smgr.c,v 1.85 2005/01/10 20:02:22 tgl Exp $
* $PostgreSQL: pgsql/src/backend/storage/smgr/smgr.c,v 1.86 2005/03/20 22:00:53 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -461,8 +461,8 @@ static void
smgr_internal_unlink(RelFileNode rnode, int which, bool isTemp, bool isRedo)
{
/*
* Get rid of any leftover buffers for the rel (shouldn't be any in
* the commit case, but there can be in the abort case).
* Get rid of any remaining buffers for the relation. bufmgr will just
* drop them without bothering to write the contents.
*/
DropRelFileNodeBuffers(rnode, isTemp, 0);
@@ -599,6 +599,12 @@ smgrtruncate(SMgrRelation reln, BlockNumber nblocks, bool isTemp)
{
BlockNumber newblks;
/*
* Get rid of any buffers for the about-to-be-deleted blocks.
* bufmgr will just drop them without bothering to write the contents.
*/
DropRelFileNodeBuffers(reln->smgr_rnode, isTemp, nblocks);
/*
* Tell the free space map to forget anything it may have stored for
* the about-to-be-deleted blocks. We want to be sure it won't return
@@ -873,6 +879,8 @@ smgr_redo(XLogRecPtr lsn, XLogRecord *record)
reln = smgropen(xlrec->rnode);
/* Can't use smgrtruncate because it would try to xlog */
/*
* First, force bufmgr to drop any buffers it has for the to-be-
* truncated blocks. We must do this, else subsequent
@@ -880,8 +888,6 @@ smgr_redo(XLogRecPtr lsn, XLogRecord *record)
*/
DropRelFileNodeBuffers(xlrec->rnode, false, xlrec->blkno);
/* Can't use smgrtruncate because it would try to xlog */
/*
* Tell the free space map to forget anything it may have stored
* for the about-to-be-deleted blocks. We want to be sure it