Re: Traffic jams in fn_extra - Mailing list pgsql-hackers

From Paul Ramsey
Subject Re: Traffic jams in fn_extra
Date
Msg-id 984D0F47C5FF4D0DB0D71A4F6EF670ED@cleverelephant.ca
Whole thread Raw
In response to Re: Traffic jams in fn_extra  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Sunday, November 24, 2013 at 4:42 PM, Tom Lane wrote:
> The real question of course is whether transaction-level caching is
> appropriate for what they're storing. If they want only statement-level
> caching then using fn_extra is often the right thing.

I'm not certain it is... we get some great effects out of the statement level stuff, and it really works great except
forthose cases where somebody else is already taking the slot (SRF_*)
 
> Also note that having the cache go away is the easy part. The hard part
> is knowing whether you've created it yet in the current transaction, and
> finding it if you have. The usual method is to keep a static variable
> pointing to it, and plugging into the transaction cleanup callback
> mechanism with a routine that'll reset the pointer to NULL at transaction
> end. For examples, look for callers of RegisterXactCallback().
> 

I'm glad you said that, because I felt too stoopid to ask :) my previous spelunking through memory contexts showed that
it'seasy to get the memory, hard to find it again. Which is why fn_extra is so appealing, it's just sitting there, and
theparent context goes away at the end of the query, so it's wonderfully simple to use... if there's not already
someonein it.
 

Thanks for the advice, it could be very helpful for my pointcloud work, since having access to a cache object during
SRF_*stuff could improve performance quite a bit, so the complexity trade-off of using the transactional context could
bewell worth it.
 

P.





pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: doPickSplit stack buffer overflow in XLogInsert?
Next
From: Andres Freund
Date:
Subject: Re: Incomplete freezing when truncating a relation during vacuum