Re: Re: bulk_multi_insert infinite loops with large rows and small fill factors

From: David Gould <daveg(at)sonic(dot)net>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org, Anand Ranganathan <arangana(at)adobe(dot)com>, Alex Eulenberg <aeulenbe(at)adobe(dot)com>, Ashokraj M <ashokraj(at)adobe(dot)com>, Hari <hari(at)adobe(dot)com>, Elein Mustain <mustain(at)adobe(dot)com>
Subject: Re: Re: bulk_multi_insert infinite loops with large rows and small fill factors
Date: 2012-12-12 12:24:07
Message-ID: 20121212042407.236b993f@jekyl.davidgould.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 12 Dec 2012 13:56:08 +0200
Heikki Linnakangas <hlinnakangas(at)vmware(dot)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(at)sonic(dot)net
If simplicity worked, the world would be overrun with insects.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2012-12-12 12:27:54 Re: Re: bulk_multi_insert infinite loops with large rows and small fill factors
Previous Message Heikki Linnakangas 2012-12-12 12:23:12 Re: Re: bulk_multi_insert infinite loops with large rows and small fill factors