Re: Optimize expresiions.

From: Richard Huxton <dev(at)archonet(dot)com>
To: han(dot)holl(at)informationslogik(dot)nl
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Optimize expresiions.
Date: 2007-01-11 11:34:06
Message-ID: 45A620AE.6030905@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

han(dot)holl(at)informationslogik(dot)nl 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 planner/optimizer that certain functions are more
> expensive than others, and should be postponed in lazy evaluation ?
> Or is there a hook in the system that would allow me too look at and maybe
> reorder expressions before they are executed ?

Not really. Perhaps look into using a functional/expressional index and
see if that does the job for you.

http://www.postgresql.org/docs/8.2/static/indexes-expressional.html
http://www.postgresql.org/docs/8.2/static/sql-createfunction.html

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alexander Farber 2007-01-11 11:37:32 Re: Knowing the length(convert(username using windows_1251_to_utf8))
Previous Message Peter Eisentraut 2007-01-11 11:30:26 Re: PG compilation