Re: Traffic jams in fn_extra

From: Paul Ramsey <pramsey(at)cleverelephant(dot)ca>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Traffic jams in fn_extra
Date: 2013-11-26 23:15:42
Message-ID: 984D0F47C5FF4D0DB0D71A4F6EF670ED@cleverelephant.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 for those 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's easy to get the memory, hard to find it again. Which is why fn_extra is so appealing, it's just sitting there, and the parent context goes away at the end of the query, so it's wonderfully simple to use... if there's not already someone in 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 be well worth it.

P.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2013-11-26 23:21:30 Re: Incomplete freezing when truncating a relation during vacuum
Previous Message Andres Freund 2013-11-26 22:19:49 Re: doPickSplit stack buffer overflow in XLogInsert?