From: Tom Lane
Subject: Re: bad plan
Date: ,
Msg-id: 13634.1110312075@sss.pgh.pa.us
(view: Whole thread, Raw)
In response to: Re: bad plan  (Gaetano Mendola)
Responses: Re: bad plan  (Richard Huxton)
Re: bad plan  (Gaetano Mendola)
List: pgsql-performance

Tree view

bad plan  (Gaetano Mendola, )
 Re: bad plan  (Richard Huxton, )
  Re: bad plan  (Gaetano Mendola, )
   Re: bad plan  (Richard Huxton, )
    Re: bad plan  (Gaetano Mendola, )
     Re: bad plan  (Richard Huxton, )
   Re: bad plan  (Tom Lane, )
    Re: bad plan  (Richard Huxton, )
     Re: bad plan  (Tom Lane, )
    Re: bad plan  (Gaetano Mendola, )

Gaetano Mendola <> 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:

From: John A Meinel
Date:
Subject: Re: Query Optimization
From: Michael Fuhr
Date:
Subject: Re: vacuum full, why multiple times ?