Re: [GENERAL] Optimize expresiions.

2007-01-12 Thread han . holl
On Thursday 11 January 2007 15:03, Adam Rich wrote: > How about this? > > select item, very_expensive_function(item) as exp, cheap > from ( Select item, cheap_function(item) as cheap > From atable where cheap_function(item) > 0 ) sub > where very_expensive_function(item) > 0 > > Well, there i

Re: [GENERAL] Optimize expresiions.

2007-01-12 Thread han . holl
On Thursday 11 January 2007 15:12, Alban Hertroys wrote: > Maybe your functions can be marked STABLE or even IMMUTABLE? That should > help the planner evaluate them less often. They are immutable, nevertheless they will have to be computed for each record. I'd just like to have some influence on

Re: [GENERAL] Optimize expresiions.

2007-01-11 Thread Alban Hertroys
[EMAIL PROTECTED] wrote: > On Thursday 11 January 2007 12:34, Richard Huxton wrote: > >>> The query would run much faster with the filter reordered. >>> Is there a way to tell the planner/optimizer that certain functions are >>> more expensive than others, and should be postponed in lazy evaluatio

Re: [GENERAL] Optimize expresiions.

2007-01-11 Thread Adam Rich
How about this? select item, very_expensive_function(item) as exp, cheap from ( Select item, cheap_function(item) as cheap From atable where cheap_function(item) > 0 ) sub where very_expensive_function(item) > 0 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTEC

Re: [GENERAL] Optimize expresiions.

2007-01-11 Thread han . holl
On Thursday 11 January 2007 12:34, Richard Huxton wrote: > > The query would run much faster with the filter reordered. > > Is there a way to tell the planner/optimizer that certain functions are > > more expensive than others, and should be postponed in lazy evaluation ? > > Or is there a hook in

Re: [GENERAL] Optimize expresiions.

2007-01-11 Thread Richard Huxton
[EMAIL PROTECTED] wrote: Now the query: select item from aview where exp > 0 and cheap > 0; will lead to a sequential scan on atable with filter: very_expensive_function(item) > 0 and cheap_function(item) > 0 The query would run much faster with the filter reordered. Is there a way to tell the