Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9226ba8

Browse files
committed
Keep heap_page_prune from marking the buffer dirty when it didn't
really change anything. Per report from Itagaki Takahiro. Fix byPavan Deolasee.
1 parent1c92724 commit9226ba8

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

‎src/backend/access/heap/pruneheap.c

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/heap/pruneheap.c,v 1.2 2007/09/21 21:25:42 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/heap/pruneheap.c,v 1.3 2007/10/24 13:05:57 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -146,17 +146,29 @@ heap_page_prune(Relation relation, Buffer buffer, TransactionId OldestXmin,
146146
intnredirected=0;
147147
intndead=0;
148148
intnunused=0;
149+
boolpage_was_full= false;
150+
TransactionIdsave_prune_xid;
149151

150152
START_CRIT_SECTION();
151153

152154
/*
153-
* Mark the page as clear of prunable tuples. If we find a tuple which
154-
* may soon become prunable, we shall set the hint again. Also clear
155-
* the "page is full" flag, since there's no point in repeating the
156-
* prune/defrag process until something else happens to the page.
155+
* Save the current pd_prune_xid and mark the page as clear of prunable
156+
* tuples. If we find a tuple which may soon become prunable, we shall set
157+
* the hint again.
157158
*/
159+
save_prune_xid= ((PageHeader)page)->pd_prune_xid;
158160
PageClearPrunable(page);
159-
PageClearFull(page);
161+
162+
/*
163+
* Also clear the "page is full" flag if it is set, since there's no point
164+
* in repeating the prune/defrag process until something else happens to
165+
* the page.
166+
*/
167+
if (PageIsFull(page))
168+
{
169+
PageClearFull(page);
170+
page_was_full= true;
171+
}
160172

161173
/* Scan the page */
162174
maxoff=PageGetMaxOffsetNumber(page);
@@ -209,10 +221,13 @@ heap_page_prune(Relation relation, Buffer buffer, TransactionId OldestXmin,
209221
else
210222
{
211223
/*
212-
* If we didn't prune anything, we have nonetheless updated the
213-
* pd_prune_xid field; treat this as a non-WAL-logged hint.
224+
* If we didn't prune anything, but have updated either the
225+
* pd_prune_xid field or the "page is full" flag, mark the buffer
226+
* dirty. This is treated as a non-WAL-logged hint.
214227
*/
215-
SetBufferCommitInfoNeedsSave(buffer);
228+
if (((PageHeader)page)->pd_prune_xid!=save_prune_xid||
229+
page_was_full)
230+
SetBufferCommitInfoNeedsSave(buffer);
216231
}
217232

218233
END_CRIT_SECTION();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp