aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/rmgrdesc/dbasedesc.c
diff options
context:
space:
mode:
authorFujii Masao <fujii@postgresql.org>2019-11-21 21:10:37 +0900
committerFujii Masao <fujii@postgresql.org>2019-11-21 21:10:37 +0900
commite6d8069522c8bde8239dd1fedfb4984efa4b3a1a (patch)
treeb0d38edfd892bdd52f3086616c36d1bce5d350ab /src/backend/access/rmgrdesc/dbasedesc.c
parent30840c92ac0c4073fb7bc8222317630571b8cf25 (diff)
downloadpostgresql-e6d8069522c8bde8239dd1fedfb4984efa4b3a1a.tar.gz
postgresql-e6d8069522c8bde8239dd1fedfb4984efa4b3a1a.zip
Make DROP DATABASE command generate less WAL records.
Previously DROP DATABASE generated as many XLOG_DBASE_DROP WAL records as the number of tablespaces that the database to drop uses. This caused the scans of shared_buffers as many times as the number of the tablespaces during recovery because WAL replay of one XLOG_DBASE_DROP record needs that full scan. This could make the recovery time longer especially when shared_buffers is large. This commit changes DROP DATABASE so that it generates only one XLOG_DBASE_DROP record, and registers the information of all the tablespaces into it. Then, WAL replay of XLOG_DBASE_DROP record needs full scan of shared_buffers only once, and which may improve the recovery performance. Author: Fujii Masao Reviewed-by: Kirk Jamison, Simon Riggs Discussion: https://postgr.es/m/CAHGQGwF8YwNH0ZaL+2wjZPkj+ji9UhC+Z4ScnG97WKtVY5L9iw@mail.gmail.com
Diffstat (limited to 'src/backend/access/rmgrdesc/dbasedesc.c')
-rw-r--r--src/backend/access/rmgrdesc/dbasedesc.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/backend/access/rmgrdesc/dbasedesc.c b/src/backend/access/rmgrdesc/dbasedesc.c
index c7d60ce10d6..d08c5758729 100644
--- a/src/backend/access/rmgrdesc/dbasedesc.c
+++ b/src/backend/access/rmgrdesc/dbasedesc.c
@@ -35,9 +35,12 @@ dbase_desc(StringInfo buf, XLogReaderState *record)
else if (info == XLOG_DBASE_DROP)
{
xl_dbase_drop_rec *xlrec = (xl_dbase_drop_rec *) rec;
+ int i;
- appendStringInfo(buf, "dir %u/%u",
- xlrec->tablespace_id, xlrec->db_id);
+ appendStringInfo(buf, "dir");
+ for (i = 0; i < xlrec->ntablespaces; i++)
+ appendStringInfo(buf, " %u/%u",
+ xlrec->tablespace_ids[i], xlrec->db_id);
}
}