| From: | han(dot)holl(at)informationslogik(dot)nl |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Optimize expresiions. |
| Date: | 2007-01-11 10:58:34 |
| Message-ID: | 200701111158.34829.han.holl@informationslogik.nl |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Hello,
Given a table:
create table atable (
item integer;
);
and a view:
create view aview as select
item,
very_expensive_function(item) as exp,
cheap_function(item) as cheap
from atable;
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 ?
Cheers,
Han Holl
| From | Date | Subject | |
|---|---|---|---|
| Next Message | km | 2007-01-11 11:19:49 | Re: PG compilation |
| Previous Message | Martijn van Oosterhout | 2007-01-11 10:50:17 | Re: Recording insert, updates, and deletes |