| From: | Joe Love <joe(at)primoweb(dot)com> |
|---|---|
| To: | pgsql-hackers(at)postgresql(dot)org |
| Subject: | Feature request: Optimizer improvement |
| Date: | 2013-10-31 19:53:46 |
| Message-ID: | CAK3BLoRQ55biBcGsE4WUAmuGVLU3QYQJ4m8-MeLSVRnnyow++w@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
In postgres 9.2 I have a function that is relatively expensive. When I
write a query such as:
select expensive_function(o.id),o.* from offeirng o where valid='Y' order
by name limit 1;
the query runs slow and appears to be running the function on each ID,
which in this case should be totally unnecessary as it really only needs to
run on 1 row.
When I rewrite the query like so:
select expensive_function(o.id), o.*
from (select *offering where valid='Y' order by name limit 1) o;
the expensive function only runs once and thus, much faster. I would think
that the optimizer could handle this situation, especially when limit or
offset is used and the expensive function is not used in a group by, order
by or where.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Kevin Grittner | 2013-10-31 19:57:47 | Re: Feature request: Optimizer improvement |
| Previous Message | Kevin Grittner | 2013-10-31 19:51:53 | Re: Record comparison compiler warning |