mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-27 08:39:28 +08:00
Take fillfactor into account in the new COPY bulk heap insert code.
Jeff Janes
This commit is contained in:
parent
32fb4546e3
commit
dea5f6cefe
@ -2093,8 +2093,11 @@ heap_multi_insert(Relation relation, HeapTuple *tuples, int ntuples,
|
|||||||
char *scratch = NULL;
|
char *scratch = NULL;
|
||||||
Page page;
|
Page page;
|
||||||
bool needwal;
|
bool needwal;
|
||||||
|
Size saveFreeSpace;
|
||||||
|
|
||||||
needwal = !(options & HEAP_INSERT_SKIP_WAL) && RelationNeedsWAL(relation);
|
needwal = !(options & HEAP_INSERT_SKIP_WAL) && RelationNeedsWAL(relation);
|
||||||
|
saveFreeSpace = RelationGetTargetPageFreeSpace(relation,
|
||||||
|
HEAP_DEFAULT_FILLFACTOR);
|
||||||
|
|
||||||
/* Toast and set header data in all the tuples */
|
/* Toast and set header data in all the tuples */
|
||||||
heaptuples = palloc(ntuples * sizeof(HeapTuple));
|
heaptuples = palloc(ntuples * sizeof(HeapTuple));
|
||||||
@ -2157,7 +2160,7 @@ heap_multi_insert(Relation relation, HeapTuple *tuples, int ntuples,
|
|||||||
{
|
{
|
||||||
HeapTuple heaptup = heaptuples[ndone + nthispage];
|
HeapTuple heaptup = heaptuples[ndone + nthispage];
|
||||||
|
|
||||||
if (PageGetHeapFreeSpace(page) < MAXALIGN(heaptup->t_len))
|
if (PageGetHeapFreeSpace(page) - saveFreeSpace < MAXALIGN(heaptup->t_len))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
RelationPutHeapTuple(relation, buffer, heaptup);
|
RelationPutHeapTuple(relation, buffer, heaptup);
|
||||||
|
Loading…
Reference in New Issue
Block a user