Skip to content

Commit dea5f6c

Browse files
committed
Take fillfactor into account in the new COPY bulk heap insert code.
Jeff Janes
1 parent 32fb454 commit dea5f6c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/backend/access/heap/heapam.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2093,8 +2093,11 @@ heap_multi_insert(Relation relation, HeapTuple *tuples, int ntuples,
20932093
char *scratch = NULL;
20942094
Page page;
20952095
bool needwal;
2096+
Size saveFreeSpace;
20962097

20972098
needwal = !(options & HEAP_INSERT_SKIP_WAL) && RelationNeedsWAL(relation);
2099+
saveFreeSpace = RelationGetTargetPageFreeSpace(relation,
2100+
HEAP_DEFAULT_FILLFACTOR);
20982101

20992102
/* Toast and set header data in all the tuples */
21002103
heaptuples = palloc(ntuples * sizeof(HeapTuple));
@@ -2157,7 +2160,7 @@ heap_multi_insert(Relation relation, HeapTuple *tuples, int ntuples,
21572160
{
21582161
HeapTuple heaptup = heaptuples[ndone + nthispage];
21592162

2160-
if (PageGetHeapFreeSpace(page) < MAXALIGN(heaptup->t_len))
2163+
if (PageGetHeapFreeSpace(page) - saveFreeSpace < MAXALIGN(heaptup->t_len))
21612164
break;
21622165

21632166
RelationPutHeapTuple(relation, buffer, heaptup);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy