From: | "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com> |
---|---|
To: | David Wheeler <david(at)kineticode(dot)com> |
Cc: | Christopher Kings-Lynne <chris(dot)kings-lynne(at)calorieking(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-performance <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: IMMUTABLE? |
Date: | 2006-05-17 15:51:40 |
Message-ID: | 20060517155139.GS26212@pervasive.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On Tue, May 16, 2006 at 07:08:51PM -0700, David Wheeler wrote:
> On May 16, 2006, at 18:29, Christopher Kings-Lynne wrote:
>
> >>Yes, but there are definitely programming cases where memoization/
> >>caching definitely helps. And it's easy to tell for a given
> >>function whether or not it really helps by simply trying it with
> >>CACHED and without.
> >>Would this be a simple thing to implement?
> >
> >It's called a "table" :)
>
> http://www.justatheory.com/computers/databases/postgresql/
> higher_order_plpgsql.html
>
> Yes, I know. :-P But it'd be easier to have a CACHED keyword, of course.
Rather than worrying about a generic form of memoization, what would be
extremely valuable would be to improve detection of the same function
being used multiple times in a query, ie:
SELECT moo(x), moo(x)/2 FROM table;
AFAIK PostgreSQL will currently execute moo(x) twice. Even if it knows
how to optimize this brain-dead example, I think there are other
examples it can't optimize right now. Having a much simpler memoization
scheme that only works on a tuple-by-tuple basis would probably
eliminate a lot of those (It wouldn't work for any executor node that
has to read it's entire input before returning anything, though, such as
sort).
--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461
From | Date | Subject | |
---|---|---|---|
Next Message | Craig A. James | 2006-05-17 15:54:52 | Optimizer: limit not taken into account |
Previous Message | Ruben Rubio Rey | 2006-05-17 15:21:14 | SQL CPU time usage |