Re: bad plan - Mailing list pgsql-performance

From Tom Lane
Subject Re: bad plan
Date
Msg-id 13634.1110312075@sss.pgh.pa.us
Whole thread Raw
In response to Re: bad plan  (Gaetano Mendola <mendola@bigfoot.com>)
Responses Re: bad plan  (Richard Huxton <dev@archonet.com>)
Re: bad plan  (Gaetano Mendola <mendola@bigfoot.com>)
List pgsql-performance
Gaetano Mendola <mendola@bigfoot.com> writes:
>> Since your query is so simple, I'm guessing v_sc_user_request is a view.
>> Can you provide the definition?

> Of course:

I don't think you've told us the whole truth about the v_sc_packages
view.  The definition as given doesn't work at all (it'll have
duplicate column names), but more to the point, if it were that simple
then the planner would fold it into the parent query.  The subquery
scan node indicates that folding did not occur.  The most likely reason
for that is that there's an ORDER BY in the view.

Putting ORDER BYs in views that you intend to use as components of other
views is a bad practice from a performance perspective...

            regards, tom lane

pgsql-performance by date:

Previous
From: Richard Huxton
Date:
Subject: Re: bad plan
Next
From: Josh Berkus
Date:
Subject: Why would writes to pgsql_tmp bottleneck at 1mb/s?