Re: avoiding tuple copying in btree index builds - Mailing list pgsql-hackers

From Tom Lane
Subject Re: avoiding tuple copying in btree index builds
Date
Msg-id 17184.1403014111@sss.pgh.pa.us
Whole thread Raw
In response to Re: avoiding tuple copying in btree index builds  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: avoiding tuple copying in btree index builds  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> On Mon, Jun 16, 2014 at 8:10 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> On a micro-optimization level, it might be worth passing the TID as
>> ItemPointer not ItemPointerData (ie, pass a pointer until we get to
>> the point of actually inserting the TID into the index tuple).
>> I'm not sure that copying odd-size structs should be assumed to be
>> efficient.

> Yeah, true.  Checking existing precedent, it looks like we usually
> pass ItemPointer rather than ItemPointerData, so it's probably a good
> idea to do this that way too for reasons of style if nothing else.  I
> kind of wonder whether it's really more efficient to pass an 8-byte
> pointer to a 6-byte structure than to just pass the structure itself,
> but it might be.

The pointer will certainly be passed in a register, or whatever passes for
registers on the particular machine architecture.  Weird-size structs,
though, tend to have arcane and not-so-efficient rules for being passed
by value.  It's not unlikely that what the compiler will do under the hood
is pass a pointer anyhow, and then do a memcpy to make a local copy in
the called function.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: UPDATE SET (a,b,c) = (SELECT ...) versus rules
Next
From: Kohei KaiGai
Date:
Subject: Re: [v9.5] Custom Plan API