pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jim C. Nasby <jnasby@pervasive.com>
To: David Wheeler <david@kineticode.com>
Cc: Christopher Kings-Lynne <chris.kings-lynne@calorieking.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-performance <pgsql-performance@postgresql.org>
Subject: Re: IMMUTABLE?
Date: Wed, 17 May 2006 10:51:40 -0500
Message-ID: <20060517155139.GS26212@pervasive.com> (raw)
In-Reply-To: <C8754CEB-0077-4B78-8355-25BFA90F19A2@kineticode.com>
References: <2D4C0FA5-DB75-45EA-91D2-7B4F6DD55083@kineticode.com>
	<5211.1147749711@sss.pgh.pa.us>
	<3F0CF576-8C6F-433C-9942-BB36F4E1A194@kineticode.com>
	<5894.1147753901@sss.pgh.pa.us>
	<719F1E6C-4695-4FD2-A73B-0E3AE173B8F0@kineticode.com>
	<446A7C69.5030905@calorieking.com>
	<C8754CEB-0077-4B78-8355-25BFA90F19A2@kineticode.com>

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@pervasive.com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461



view thread (11+ messages)

Message-ID: <20060517155139.GS26212@pervasive.com>
Permalink:  ../20060517155139.GS26212@pervasive.com/
Also on:    postgresql.org/message-id/20060517155139.GS26212@pervasive.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: jnasby@pervasive.com, david@kineticode.com, chris.kings-lynne@calorieking.com, tgl@sss.pgh.pa.us
  Subject: Re: IMMUTABLE?
  In-Reply-To: <20060517155139.GS26212@pervasive.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox