Re: Detection of nested function calls

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Hugo Mercier <hugo(dot)mercier(at)oslandia(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Detection of nested function calls
Date: 2013-10-28 18:05:07
Message-ID: 20131028180507.GB20248@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2013-10-28 13:41:46 -0400, Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> > On 2013-10-28 12:42:28 -0400, Tom Lane wrote:
> >> Meh. If you don't include a function pointer you will still need the OID
> >> of the datatype or the decompression function, so it's not like omitting
> >> it is free.
>
> > That's what I thought at first too - but I am not sure it's actually
> > true. The reason we need to include the toastrelid in varatt_externals
> > (which I guess you are thinking of, like me) is that we need to be able
> > to resolve "naked" Datums to their original value without any context.
> > But at the locations where we'd need to call the memory
> > representation->disk conversion function we should have a TupleDesc with
> > type information, so we could lookup the needed information there.
>
> I don't think that's a safe assumption at all. We need to be able to do
> flattening anywhere PG_DETOAST_DATUM() can be called.

I am not sure we want things to work along those lines. I'd rather make
PG_DETOAST_DATUM pass along such in-memory Datums unchanged and require
any funtion that wants to poke into into the Datum in detail to know
about the different representations. That will require a bit more
widespread changes in functions using those types natively, but it will
make it more realistic to use the optimization across much of the code
that detoasts Datums generally.

> In any case, my point here is largely that I don't want to add a catalog
> lookup to the operation. This whole proposal is basically about trading
> greater short-term memory usage to gain speed, so griping about an extra 4
> or so bytes per value seems to me to be missing the point completely.
> Or to put it even more bluntly: if you've not realized that the extra
> palloc overhead of an out-of-line instance of the datum will swamp what
> we're talking about here, you need to realize that.

I am not arguing against this at all though.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2013-10-28 18:10:48 Re: better atomics
Previous Message Robert Haas 2013-10-28 17:55:41 Re: RULE regression test fragility?