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

Commit8e03eb9

Browse files
committed
Revert most of39b66a9
Reverts most of commit39b66a9, which was found to cause significantregression for REFRESH MATERIALIZED VIEW. This means only rows insertedby heap_multi_insert will benefit from the optimization, implemented incommit7db0cd2.Reported-by: Masahiko SawadaDiscussion:https://postgr.es/m/CAD21AoA%3D%3Df2VSw3c-Cp_y%3DWLKHMKc1D6s7g3YWsCOvgaYPpJcg%40mail.gmail.com
1 parent8895923 commit8e03eb9

File tree

2 files changed

+12
-84
lines changed

2 files changed

+12
-84
lines changed

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

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2063,12 +2063,8 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
20632063
TransactionIdxid=GetCurrentTransactionId();
20642064
HeapTupleheaptup;
20652065
Bufferbuffer;
2066-
Pagepage=NULL;
20672066
Buffervmbuffer=InvalidBuffer;
2068-
boolstarting_with_empty_page;
20692067
boolall_visible_cleared= false;
2070-
boolall_frozen_set= false;
2071-
uint8vmstatus=0;
20722068

20732069
/* Cheap, simplistic check that the tuple matches the rel's rowtype. */
20742070
Assert(HeapTupleHeaderGetNatts(tup->t_data) <=
@@ -2085,36 +2081,11 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
20852081
/*
20862082
* Find buffer to insert this tuple into. If the page is all visible,
20872083
* this will also pin the requisite visibility map page.
2088-
*
2089-
* Also pin visibility map page if COPY FREEZE inserts tuples into an
2090-
* empty page. See all_frozen_set below.
20912084
*/
20922085
buffer=RelationGetBufferForTuple(relation,heaptup->t_len,
20932086
InvalidBuffer,options,bistate,
20942087
&vmbuffer,NULL);
20952088

2096-
2097-
/*
2098-
* If we're inserting frozen entry into an empty page, set visibility map
2099-
* bits and PageAllVisible() hint.
2100-
*
2101-
* If we're inserting frozen entry into already all_frozen page, preserve
2102-
* this state.
2103-
*/
2104-
if (options&HEAP_INSERT_FROZEN)
2105-
{
2106-
page=BufferGetPage(buffer);
2107-
2108-
starting_with_empty_page=PageGetMaxOffsetNumber(page)==0;
2109-
2110-
if (visibilitymap_pin_ok(BufferGetBlockNumber(buffer),vmbuffer))
2111-
vmstatus=visibilitymap_get_status(relation,
2112-
BufferGetBlockNumber(buffer),&vmbuffer);
2113-
2114-
if ((starting_with_empty_page||vmstatus&VISIBILITYMAP_ALL_FROZEN))
2115-
all_frozen_set= true;
2116-
}
2117-
21182089
/*
21192090
* We're about to do the actual insert -- but check for conflict first, to
21202091
* avoid possibly having to roll back work we've just done.
@@ -2138,28 +2109,14 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
21382109
RelationPutHeapTuple(relation,buffer,heaptup,
21392110
(options&HEAP_INSERT_SPECULATIVE)!=0);
21402111

2141-
/*
2142-
* If the page is all visible, need to clear that, unless we're only going
2143-
* to add further frozen rows to it.
2144-
*
2145-
* If we're only adding already frozen rows to a page that was empty or
2146-
* marked as all visible, mark it as all-visible.
2147-
*/
2148-
if (PageIsAllVisible(BufferGetPage(buffer))&& !(options&HEAP_INSERT_FROZEN))
2112+
if (PageIsAllVisible(BufferGetPage(buffer)))
21492113
{
21502114
all_visible_cleared= true;
21512115
PageClearAllVisible(BufferGetPage(buffer));
21522116
visibilitymap_clear(relation,
21532117
ItemPointerGetBlockNumber(&(heaptup->t_self)),
21542118
vmbuffer,VISIBILITYMAP_VALID_BITS);
21552119
}
2156-
elseif (all_frozen_set)
2157-
{
2158-
/* We only ever set all_frozen_set after reading the page. */
2159-
Assert(page);
2160-
2161-
PageSetAllVisible(page);
2162-
}
21632120

21642121
/*
21652122
* XXX Should we set PageSetPrunable on this page ?
@@ -2207,8 +2164,6 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
22072164
xlrec.flags=0;
22082165
if (all_visible_cleared)
22092166
xlrec.flags |=XLH_INSERT_ALL_VISIBLE_CLEARED;
2210-
if (all_frozen_set)
2211-
xlrec.flags=XLH_INSERT_ALL_FROZEN_SET;
22122167
if (options&HEAP_INSERT_SPECULATIVE)
22132168
xlrec.flags |=XLH_INSERT_IS_SPECULATIVE;
22142169
Assert(ItemPointerGetBlockNumber(&heaptup->t_self)==BufferGetBlockNumber(buffer));
@@ -2257,29 +2212,6 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
22572212

22582213
END_CRIT_SECTION();
22592214

2260-
/*
2261-
* If we've frozen everything on the page, update the visibilitymap. We're
2262-
* already holding pin on the vmbuffer.
2263-
*
2264-
* No need to update the visibilitymap if it had all_frozen bit set before
2265-
* this insertion.
2266-
*/
2267-
if (all_frozen_set&& ((vmstatus&VISIBILITYMAP_ALL_FROZEN)==0))
2268-
{
2269-
Assert(PageIsAllVisible(page));
2270-
Assert(visibilitymap_pin_ok(BufferGetBlockNumber(buffer),vmbuffer));
2271-
2272-
/*
2273-
* It's fine to use InvalidTransactionId here - this is only used when
2274-
* HEAP_INSERT_FROZEN is specified, which intentionally violates
2275-
* visibility rules.
2276-
*/
2277-
visibilitymap_set(relation,BufferGetBlockNumber(buffer),buffer,
2278-
InvalidXLogRecPtr,vmbuffer,
2279-
InvalidTransactionId,
2280-
VISIBILITYMAP_ALL_VISIBLE |VISIBILITYMAP_ALL_FROZEN);
2281-
}
2282-
22832215
UnlockReleaseBuffer(buffer);
22842216
if (vmbuffer!=InvalidBuffer)
22852217
ReleaseBuffer(vmbuffer);
@@ -8946,10 +8878,6 @@ heap_xlog_insert(XLogReaderState *record)
89468878
ItemPointerSetBlockNumber(&target_tid,blkno);
89478879
ItemPointerSetOffsetNumber(&target_tid,xlrec->offnum);
89488880

8949-
/* check that the mutually exclusive flags are not both set */
8950-
Assert(!((xlrec->flags&XLH_INSERT_ALL_VISIBLE_CLEARED)&&
8951-
(xlrec->flags&XLH_INSERT_ALL_FROZEN_SET)));
8952-
89538881
/*
89548882
* The visibility map may need to be fixed even if the heap page is
89558883
* already up-to-date.

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -407,19 +407,19 @@ RelationGetBufferForTuple(Relation relation, Size len,
407407
* target.
408408
*/
409409
targetBlock=GetPageWithFreeSpace(relation,targetFreeSpace);
410-
}
411410

412-
/*
413-
* If the FSM knows nothing of the rel, try the last page before we give
414-
* up and extend. This avoids one-tuple-per-page syndrome during
415-
* bootstrapping or in a recently-started system.
416-
*/
417-
if (targetBlock==InvalidBlockNumber)
418-
{
419-
BlockNumbernblocks=RelationGetNumberOfBlocks(relation);
411+
/*
412+
* If the FSM knows nothing of the rel, try the last page before we
413+
* give up and extend. This avoids one-tuple-per-page syndrome during
414+
* bootstrapping or in a recently-started system.
415+
*/
416+
if (targetBlock==InvalidBlockNumber)
417+
{
418+
BlockNumbernblocks=RelationGetNumberOfBlocks(relation);
420419

421-
if (nblocks>0)
422-
targetBlock=nblocks-1;
420+
if (nblocks>0)
421+
targetBlock=nblocks-1;
422+
}
423423
}
424424

425425
loop:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp