Re: Manipulating complex types as non-contiguous structures in-memory

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: hlinnaka(at)iki(dot)fi
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Manipulating complex types as non-contiguous structures in-memory
Date: 2015-04-17 12:58:02
Message-ID: 4689.1429275482@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Heikki Linnakangas <hlinnaka(at)iki(dot)fi> writes:
> On 03/28/2015 11:24 PM, Tom Lane wrote:
>> + * Macros for iterating through elements of a flat or expanded array.

> How about a struct instead?

> struct ArrayIter {
> Datum datumptr;
> bool isnullptr;
> char dataptr;
> bits8 bitmapptr;
> int bitmask
> }

> Seems more natural.

Yes, and much less efficient I'm afraid. Most compilers would be unable
to put the variables into registers, which is important for these inner
loops.

> How about turning these into functions?

Likewise. The point of doing it like this was to avoid taking an
efficiency hit compared to the existing code.

It's conceivable that we could avoid such a hit by marking the functions
all "inline", but I'm not certain that they'd get inlined, and the
question of whether the variables could be in registers would remain.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2015-04-17 13:11:36 Re: pg_upgrade in 9.5 broken for adminpack
Previous Message Stephen Frost 2015-04-17 11:54:25 Re: INSERT ... ON CONFLICT IGNORE (and UPDATE) 3.0