Function result cacheing

From: Philip Warner <pjw(at)rhyme(dot)com(dot)au>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Function result cacheing
Date: 2002-08-17 03:18:02
Message-ID: 5.1.0.14.0.20020817130905.02920118@mail.rhyme.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


This has been discussed before in the context of misunderstanding the
meaning of 'iscachable', but I now have a use for cached function results,
and have seen at least one other posting with a similar need.

The reason I need it is that I have a few functions that do recursive
inheritance lookups going up a converging inheritance tree. Typically this
function will be called on several hundred objects in a single select
statement. Because of inheritance, it ends up with several thousand
function calls, each of which is non-trivial.

A solution that would be useful for me would be:

If a function is marked 'invariant' (or something similar), then

- cache the most recently used 20 calls (config item) iff the args were
less than 1K in total storage (ie. don't cache large text blocks),

- calculate a very simple checksum on the args

- when a function is to be evaluated, calc the checksum and if a match is
found, compare the args, and if they all match, return the result.

I would anticipate deleting the cache when the current command exits,
and/or certainly when a TX ends.

Obviously this is not a 7.3 item, but would people support such
functionality going into a future version?

----------------------------------------------------------------
Philip Warner | __---_____
Albatross Consulting Pty. Ltd. |----/ - \
(A.B.N. 75 008 659 498) | /(@) ______---_
Tel: (+61) 0500 83 82 81 | _________ \
Fax: (+61) 0500 83 82 82 | ___________ |
Http://www.rhyme.com.au | / \|
| --________--
PGP key available upon request, | /
and from pgp5.ai.mit.edu:11371 |/

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2002-08-17 03:55:43 Re: XLogDir
Previous Message Tom Lane 2002-08-17 03:10:22 Re: XLogDir