From e6d8069522c8bde8239dd1fedfb4984efa4b3a1a Mon Sep 17 00:00:00 2001 From: Fujii Masao Date: Thu, 21 Nov 2019 21:10:37 +0900 Subject: 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 --- src/include/commands/dbcommands_xlog.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/include/commands/dbcommands_xlog.h') diff --git a/src/include/commands/dbcommands_xlog.h b/src/include/commands/dbcommands_xlog.h index 46be8a615ac..4e8a442c89f 100644 --- a/src/include/commands/dbcommands_xlog.h +++ b/src/include/commands/dbcommands_xlog.h @@ -32,10 +32,11 @@ typedef struct xl_dbase_create_rec typedef struct xl_dbase_drop_rec { - /* Records dropping of a single subdirectory incl. contents */ Oid db_id; - Oid tablespace_id; + int ntablespaces; /* number of tablespace IDs */ + Oid tablespace_ids[FLEXIBLE_ARRAY_MEMBER]; } xl_dbase_drop_rec; +#define MinSizeOfDbaseDropRec offsetof(xl_dbase_drop_rec, tablespace_ids) extern void dbase_redo(XLogReaderState *rptr); extern void dbase_desc(StringInfo buf, XLogReaderState *rptr); -- cgit v1.2.3