|
8 | 8 | * |
9 | 9 | * |
10 | 10 | * IDENTIFICATION |
11 | | - * $PostgreSQL: pgsql/src/backend/access/heap/pruneheap.c,v 1.1 2007/09/20 17:56:30 tgl Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/access/heap/pruneheap.c,v 1.2 2007/09/21 21:25:42 tgl Exp $ |
12 | 12 | * |
13 | 13 | *------------------------------------------------------------------------- |
14 | 14 | */ |
@@ -63,9 +63,10 @@ heap_page_prune_opt(Relation relation, Buffer buffer, TransactionId OldestXmin) |
63 | 63 | /* |
64 | 64 | * Let's see if we really need pruning. |
65 | 65 | * |
66 | | - * Forget it if page is not hinted to contain something prunable |
| 66 | + * Forget it if page is not hinted to contain something prunable that's |
| 67 | + * older than OldestXmin. |
67 | 68 | */ |
68 | | -if (!PageIsPrunable(dp)) |
| 69 | +if (!PageIsPrunable(dp,OldestXmin)) |
69 | 70 | return; |
70 | 71 |
|
71 | 72 | /* |
@@ -93,6 +94,8 @@ heap_page_prune_opt(Relation relation, Buffer buffer, TransactionId OldestXmin) |
93 | 94 | /* |
94 | 95 | * Now that we have buffer lock, get accurate information about the |
95 | 96 | * page's free space, and recheck the heuristic about whether to prune. |
| 97 | + * (We needn't recheck PageIsPrunable, since no one else could have |
| 98 | + * pruned while we hold pin.) |
96 | 99 | */ |
97 | 100 | if (PageIsFull(dp)||PageGetHeapFreeSpace((Page)dp)<minfree) |
98 | 101 | { |
@@ -147,7 +150,7 @@ heap_page_prune(Relation relation, Buffer buffer, TransactionId OldestXmin, |
147 | 150 | START_CRIT_SECTION(); |
148 | 151 |
|
149 | 152 | /* |
150 | | - * Mark the page as clear of prunable tuples. If we find a tuple which |
| 153 | + * Mark the page as clear of prunable tuples.If we find a tuple which |
151 | 154 | * may soon become prunable, we shall set the hint again. Also clear |
152 | 155 | * the "page is full" flag, since there's no point in repeating the |
153 | 156 | * prune/defrag process until something else happens to the page. |
@@ -203,6 +206,14 @@ heap_page_prune(Relation relation, Buffer buffer, TransactionId OldestXmin, |
203 | 206 | PageSetLSN(BufferGetPage(buffer),recptr); |
204 | 207 | } |
205 | 208 | } |
| 209 | +else |
| 210 | +{ |
| 211 | +/* |
| 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. |
| 214 | + */ |
| 215 | +SetBufferCommitInfoNeedsSave(buffer); |
| 216 | +} |
206 | 217 |
|
207 | 218 | END_CRIT_SECTION(); |
208 | 219 |
|
@@ -392,18 +403,18 @@ heap_prune_chain(Relation relation, Buffer buffer, OffsetNumber rootoffnum, |
392 | 403 | caseHEAPTUPLE_RECENTLY_DEAD: |
393 | 404 | recent_dead= true; |
394 | 405 | /* |
395 | | - * This tuple may soon become DEAD.Re-setthe hintbit so |
| 406 | + * This tuple may soon become DEAD. Updatethe hintfield so |
396 | 407 | * that the page is reconsidered for pruning in future. |
397 | 408 | */ |
398 | | -PageSetPrunable(dp); |
| 409 | +PageSetPrunable(dp,HeapTupleHeaderGetXmax(htup)); |
399 | 410 | break; |
400 | 411 |
|
401 | 412 | caseHEAPTUPLE_DELETE_IN_PROGRESS: |
402 | 413 | /* |
403 | | - * This tuple may soon become DEAD.Re-setthe hintbit so |
| 414 | + * This tuple may soon become DEAD. Updatethe hintfield so |
404 | 415 | * that the page is reconsidered for pruning in future. |
405 | 416 | */ |
406 | | -PageSetPrunable(dp); |
| 417 | +PageSetPrunable(dp,HeapTupleHeaderGetXmax(htup)); |
407 | 418 | break; |
408 | 419 |
|
409 | 420 | caseHEAPTUPLE_LIVE: |
|