Re: Storing a dynahash for an entire connection or transaction?

From: Tom Dunstan <pgsql(at)tomd(dot)cc>
To: Volkan YAZICI <yazicivo(at)ttnet(dot)net(dot)tr>
Cc: Greg Mitchell <gmitchell(at)atdesk(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Storing a dynahash for an entire connection or transaction?
Date: 2006-11-27 20:11:53
Message-ID: 456B4689.7060307@tomd.cc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Volkan YAZICI wrote:
>> What I'd like to do is change the way I store this hash so that it
>> doesn't need to be as frequently updated. I'm open to most any solution.
>> One type rarely ever has new values (maybe once every several months)
>> and the other gets new values once a night.
>
> You may want to cache these values using a static variable (which will
> make itself to be valid per session) that stores its values in the
> (for instance) TopTransactionContext.

That's the obvious solution (or perhaps in CurTransactionContext), but
when the function is called in a subsequent transaction, how does it
determine that the static pointer was allocated from a context which has
since vanished? I suppose that you could store the memory context
pointer for later comparison, but while it seems unlikely that you'd get
the same pointer twice in a row, that's not exactly a guarantee.

I note (reading src/backend/utils/mmgr/README) that there are reset and
delete methods attached to memory contexts, so perhaps the best way to
accomplish this would be to create a separate memory context as a child
of CurTransactionContext, and register a cleanup function which could
clear the static var when the context is torn down. I'm assuming that
those methods do get called in such cases, but I haven't delved much.

Cheers

Tom

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2006-11-27 20:16:49 Re: Potential to_char localization bug
Previous Message Simon Riggs 2006-11-27 20:11:18 Re: PrivateRefCount (for 8.3)