pgsql: Improve the performance of relation deletes during recovery.

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Improve the performance of relation deletes during recovery.
Date: 2018-07-04 17:59:39
Message-ID: E1fam43-0006uL-8a@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Improve the performance of relation deletes during recovery.

When multiple relations are deleted at the same transaction,
the files of those relations are deleted by one call to smgrdounlinkall(),
which leads to scan whole shared_buffers only one time. OTOH,
previously, during recovery, smgrdounlink() (not smgrdounlinkall()) was
called for each file to delete, which led to scan shared_buffers
multiple times. Obviously this could cause to increase the WAL replay
time very much especially when shared_buffers was huge.

To alleviate this situation, this commit changes the recovery so that
it also calls smgrdounlinkall() only one time to delete multiple
relation files.

This is just fix for oversight of commit 279628a0a7, not new feature.
So, per discussion on pgsql-hackers, we concluded to backpatch this
to all supported versions.

Author: Fujii Masao
Reviewed-by: Michael Paquier, Andres Freund, Thomas Munro, Kyotaro Horiguchi, Takayuki Tsunakawa
Discussion: https://postgr.es/m/CAHGQGwHVQkdfDqtvGVkty+19cQakAydXn1etGND3X0PHbZ3+6w@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/b41669118c00e25376a6c9ac991e0d074990484a

Modified Files
--------------
src/backend/access/transam/twophase.c | 9 ++-------
src/backend/access/transam/xact.c | 25 +++--------------------
src/backend/storage/smgr/md.c | 38 +++++++++++++++++++++++++++++++++++
src/include/storage/smgr.h | 1 +
4 files changed, 44 insertions(+), 29 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2018-07-04 18:00:12 pgsql: Improve the performance of relation deletes during recovery.
Previous Message Alvaro Herrera 2018-07-04 17:15:19 Re: pgsql: Fix crash when ALTER TABLE recreates indexes on partitions