summaryrefslogtreecommitdiff
path: root/src/backend/storage/smgr/smgr.c
diff options
context:
space:
mode:
authorAmit Kapila2021-01-13 02:16:11 +0000
committerAmit Kapila2021-01-13 02:16:11 +0000
commitbea449c635c0e68e21610593594c1e5d52842cdd (patch)
tree3bb08390afd7bbcc4f846b3cfa96efd2dc24f05c /src/backend/storage/smgr/smgr.c
parentfce7d0e6efbef304e81846c75eddf73099628d10 (diff)
Optimize DropRelFileNodesAllBuffers() for recovery.
Similar to commit d6ad34f341, this patch optimizes DropRelFileNodesAllBuffers() by avoiding the complete buffer pool scan and instead find the buffers to be invalidated by doing lookups in the BufMapping table. This optimization helps operations where the relation files need to be removed like Truncate, Drop, Abort of Create Table, etc. Author: Kirk Jamison Reviewed-by: Kyotaro Horiguchi, Takayuki Tsunakawa, and Amit Kapila Tested-By: Haiying Tang Discussion: https://postgr.es/m/OSBPR01MB3207DCA7EC725FDD661B3EDAEF660@OSBPR01MB3207.jpnprd01.prod.outlook.com
Diffstat (limited to 'src/backend/storage/smgr/smgr.c')
-rw-r--r--src/backend/storage/smgr/smgr.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/backend/storage/smgr/smgr.c b/src/backend/storage/smgr/smgr.c
index af603c3db3b..4dc24649df9 100644
--- a/src/backend/storage/smgr/smgr.c
+++ b/src/backend/storage/smgr/smgr.c
@@ -391,6 +391,12 @@ smgrdounlinkall(SMgrRelation *rels, int nrels, bool isRedo)
return;
/*
+ * Get rid of any remaining buffers for the relations. bufmgr will just
+ * drop them without bothering to write the contents.
+ */
+ DropRelFileNodesAllBuffers(rels, nrels);
+
+ /*
* create an array which contains all relations to be dropped, and close
* each relation's forks at the smgr level while at it
*/
@@ -408,12 +414,6 @@ smgrdounlinkall(SMgrRelation *rels, int nrels, bool isRedo)
}
/*
- * Get rid of any remaining buffers for the relations. bufmgr will just
- * drop them without bothering to write the contents.
- */
- DropRelFileNodesAllBuffers(rnodes, nrels);
-
- /*
* It'd be nice to tell the stats collector to forget them immediately,
* too. But we can't because we don't know the OIDs.
*/