Re: Fixed length data types issue

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Gregory Stark <stark(at)enterprisedb(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fixed length data types issue
Date: 2006-09-07 12:30:14
Message-ID: 20060907123014.GK10093@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Sep 07, 2006 at 01:11:49PM +0100, Gregory Stark wrote:
>
> Martijn van Oosterhout <kleptog(at)svana(dot)org> writes:
>
> > The fundamental property of a Datum is that you can pass it by value to
> > a C function. This generally means it has to fit in a register. On the
> > whole, the CPU register size is the same as the pointer size, so
> > 2*sizeof(pointer) is unlikely to fit...
>
> Not having it fit in a register might impact performance but it certainly
> isn't a requirement. You can pass whole structs by value in modern C. (And by
> modern here I don't mean C99, this has been supported since before ANSI and is
> required by *C89*).

Sure, the C compiler pushes it on the stack and passes a pointer to the
function. Pass-by-value in this context means "pass a reference to a
copy". It works, but it's not very efficient.

The C compiler also allows you create struct variables and assign them
as if they were plain variables. The assembly code to make this work
isn't pretty. You're proposing doing it for everywhere in the backend,
which seems like a huge cost for very little gain.

A better approach would be to revive the proposal for a variable-length
varlena header. It's four-bytes fixed because that's easy, but given most
values are under 4K you could come up with a coding scheme that cut the
header for such Datums to only 2 bytes, or less...

Have a ncie day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2006-09-07 12:33:29 Re: [HACKERS] Timezone List
Previous Message Gregory Stark 2006-09-07 12:27:01 Re: Fixed length data types issue