From: | "Mike" <mike(at)mrhost(dot)ca> |
---|---|
To: | "Michael Fuhr" <mike(at)fuhr(dot)org> |
Cc: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Caching/Indexing Function Output |
Date: | 2004-12-24 10:45:37 |
Message-ID: | 1ce701c4e9a5$b4755300$0201000a@ehj9vn81i9b95wa |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> On Thu, Dec 23, 2004 at 01:22:42PM -0800, Mike wrote:
>
> > My question is- is there anyway, since a call to sp_host('10.0.0.1')
will
> > always
> > return the same value (the primary key/sequence value from the
ip_addresses
> > table), to cache/index that value somehow, so anytime I ever call that
same
> > function, with the same argument, it returns a cached/indexed value?
>
> Some procedural languages (PL/Tcl, PL/Python; also PL/Perl in 8.0)
> have global data that you could use as a cache. The function would
> still be called each time, but you could at least use the cache to
> save the cost of a database query.
All the functions I wrote are in C-
So yeah, I guess I could have a global key/value hash that I keep up from
inside the
functions, and if the ip address exists, then return the value, otherwise
actually
execute the function.
I could probably use something like libmm if I didn't have access to global
vars, and
store them in shared memory- I was just hoping to have something that
postgres
would manage automagically for me. :)
It would also be cool if the planner could decide which to use- ie it would
be
considered cheaper to use the cache then call the function if the ip address
was
listed.
Thanks-
Mike
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2004-12-24 14:33:39 | Re: ISO_8859_8 encoding |
Previous Message | Michael Fuhr | 2004-12-24 04:20:44 | Re: Caching/Indexing Function Output |