Re: Re: bulk_multi_insert infinite loops with large rows and small fill factors - Mailing list pgsql-hackers

From David Gould
Subject Re: Re: bulk_multi_insert infinite loops with large rows and small fill factors
Date
Msg-id 20121212042407.236b993f@jekyl.davidgould.org
Whole thread Raw
In response to Re: Re: bulk_multi_insert infinite loops with large rows and small fill factors  (Heikki Linnakangas <hlinnakangas@vmware.com>)
Responses Re: Re: bulk_multi_insert infinite loops with large rows and small fill factors
List pgsql-hackers
On Wed, 12 Dec 2012 13:56:08 +0200
Heikki Linnakangas <hlinnakangas@vmware.com> wrote:

> However, RelationGetBufferForTuple() won't return such 
> a page, it guarantees that the first tuple does indeed fit on the page 
> it returns. For the same reason, the later check that at least one tuple 
> was actually placed on the page is not necessary.
> 
> I committed a slightly different version, which unconditionally puts the 
> first tuple on the page, and only applies the freespace check to the 
> subsequent tuples. Since RelationGetBufferForTuple() guarantees that the 
> first tuple fits, we can trust that, like heap_insert does.
> 
> --- a/src/backend/access/heap/heapam.c
> +++ b/src/backend/access/heap/heapam.c
> @@ -2172,8 +2172,12 @@ heap_multi_insert(Relation relation, HeapTuple 
> *tuples, int ntuples,
>           /* NO EREPORT(ERROR) from here till changes are logged */
>           START_CRIT_SECTION();
> 
> -        /* Put as many tuples as fit on this page */
> -        for (nthispage = 0; ndone + nthispage < ntuples; nthispage++)
> +        /*
> +         * ()  has ensured that the first tuple fits.
> +         * Put that on the page, and then as many other tuples as fit.
> +         */
> +        RelationPutHeapTuple(relation, buffer, heaptuples[ndone]);
> +        for (nthispage = 1; ndone + nthispage < ntuples; nthispage++)
>           {
>               HeapTuple    heaptup = heaptuples[ndone + nthispage];

I don't know if this is the same thing. At least in the comments I was
reading trying to figure this out there was some concern that someone
else could change the space on the page. Does RelationGetBufferForTuple()
guarantee against this too?

-dg

-- 
David Gould              510 282 0869         daveg@sonic.net
If simplicity worked, the world would be overrun with insects.



pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: Re: bulk_multi_insert infinite loops with large rows and small fill factors
Next
From: Heikki Linnakangas
Date:
Subject: Re: Re: bulk_multi_insert infinite loops with large rows and small fill factors