mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
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
This commit is contained in:
@ -5516,7 +5516,6 @@ xact_redo_commit(xl_xact_parsed_commit *parsed,
|
||||
RepOriginId origin_id)
|
||||
{
|
||||
TransactionId max_xid;
|
||||
int i;
|
||||
TimestampTz commit_time;
|
||||
|
||||
Assert(TransactionIdIsValid(xid));
|
||||
@ -5635,16 +5634,8 @@ xact_redo_commit(xl_xact_parsed_commit *parsed,
|
||||
*/
|
||||
XLogFlush(lsn);
|
||||
|
||||
for (i = 0; i < parsed->nrels; i++)
|
||||
{
|
||||
SMgrRelation srel = smgropen(parsed->xnodes[i], InvalidBackendId);
|
||||
ForkNumber fork;
|
||||
|
||||
for (fork = 0; fork <= MAX_FORKNUM; fork++)
|
||||
XLogDropRelation(parsed->xnodes[i], fork);
|
||||
smgrdounlink(srel, true);
|
||||
smgrclose(srel);
|
||||
}
|
||||
/* Make sure files supposed to be dropped are dropped */
|
||||
DropRelationFiles(parsed->xnodes, parsed->nrels, true);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -5683,7 +5674,6 @@ xact_redo_commit(xl_xact_parsed_commit *parsed,
|
||||
static void
|
||||
xact_redo_abort(xl_xact_parsed_abort *parsed, TransactionId xid)
|
||||
{
|
||||
int i;
|
||||
TransactionId max_xid;
|
||||
|
||||
Assert(TransactionIdIsValid(xid));
|
||||
@ -5748,16 +5738,7 @@ xact_redo_abort(xl_xact_parsed_abort *parsed, TransactionId xid)
|
||||
}
|
||||
|
||||
/* Make sure files supposed to be dropped are dropped */
|
||||
for (i = 0; i < parsed->nrels; i++)
|
||||
{
|
||||
SMgrRelation srel = smgropen(parsed->xnodes[i], InvalidBackendId);
|
||||
ForkNumber fork;
|
||||
|
||||
for (fork = 0; fork <= MAX_FORKNUM; fork++)
|
||||
XLogDropRelation(parsed->xnodes[i], fork);
|
||||
smgrdounlink(srel, true);
|
||||
smgrclose(srel);
|
||||
}
|
||||
DropRelationFiles(parsed->xnodes, parsed->nrels, true);
|
||||
}
|
||||
|
||||
void
|
||||
|
Reference in New Issue
Block a user