Re: [GENERAL] Custom cache implemented in a postgresql C function

2010-10-21 Thread Gabi Julien
Thanks to all of you. This was very good feedback. I'll use the one cache per process suggestion of Tom Lane. This will be the easiest to implement. On Thursday 21 October 2010 11:14:40 A.M. wrote: > > On Oct 20, 2010, at 7:44 PM, Gabi Julien wrote: > > > Hi, > > > > Here is my problem: I have

Re: [GENERAL] Custom cache implemented in a postgresql C function

2010-10-21 Thread A.M.
On Oct 20, 2010, at 7:44 PM, Gabi Julien wrote: > Hi, > > Here is my problem: I have a postgresql C function that looks like this: > > Datum filter(PG_FUNCTION_ARGS); > > It takes identifiers and queries a bunch of tables and ends up returning true > or false. So far nothing difficult except

Re: [GENERAL] Custom cache implemented in a postgresql C function

2010-10-21 Thread Tom Lane
Alban Hertroys writes: > That sounds like your function would classify as a STABLE function > within Postgres, did you define it as such? Postgres will cache the > results of STABLE (and IMMUTABLE) functions all by itself, in which > case you may not need your custom cache. Uh, no it won't. It w

Re: [GENERAL] Custom cache implemented in a postgresql C function

2010-10-21 Thread Alban Hertroys
On 21 Oct 2010, at 1:44, Gabi Julien wrote: > Hi, > > Here is my problem: I have a postgresql C function that looks like this: > > Datum filter(PG_FUNCTION_ARGS); > > It takes identifiers and queries a bunch of tables and ends up returning true > or false. So far nothing difficult except that

Re: [GENERAL] Custom cache implemented in a postgresql C function

2010-10-20 Thread Tom Lane
Gabi Julien writes: > In my case, I do not know how big my cache will be. That makes it awfully hard to use shared memory. > If shared memory turns out too difficult to use, I could create > separate caches for each postgresql processes. That's what I'd recommend. A big advantage of private ca

Re: [GENERAL] Custom cache implemented in a postgresql C function

2010-10-20 Thread Rob Sargent
Are you sure you cache needs to grow endlessly? Otherwise you could use RequestAddinShmemSpace and manage you're map within that space, perhaps "overwriting" chunks on an LRU basis or a rollover. i.e. Grab it all and do your own management within that single block of shmem. Caches are best for thi

[GENERAL] Custom cache implemented in a postgresql C function

2010-10-20 Thread Gabi Julien
Hi, Here is my problem: I have a postgresql C function that looks like this: Datum filter(PG_FUNCTION_ARGS); It takes identifiers and queries a bunch of tables and ends up returning true or false. So far nothing difficult except that we want better performance. The function was already optimiz