Re: [GENERAL] optimizing common subqueries

2005-10-05 Thread Jim C. Nasby
You can put the complex query into a subquery in the from clause and PostgreSQL will normally do a good job with that. See one of the other replies in this thread. On Wed, Oct 05, 2005 at 11:23:20AM -0400, John D. Burger wrote: > As I understand it, Postgres's query planner considers only trees of

Re: [GENERAL] optimizing common subqueries

2005-10-05 Thread John D. Burger
As I understand it, Postgres's query planner considers only trees of joins - I don't know what the technical implications are of using DAG plans, other than the obvious blowup in planning space. I was recently in a similar situation, where a script essentially needed to do a self-join on the r

[GENERAL] optimizing common subqueries

2005-10-04 Thread Kevin Murphy
My understanding is that PG does not eliminate common subqueries within complex queries. I just wanted to confirm this. I also tried wrapping subqueries in STABLE or IMMUTABLE functions returning SETOF, but from the PG 8.0.3 log, I see that the function is invoked redundantly anyway. I know