X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3AAB25643E for ; Tue, 8 Mar 2005 20:01:32 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 81309-01 for ; Tue, 8 Mar 2005 20:01:24 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 600BA56378 for ; Tue, 8 Mar 2005 20:01:23 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j28K1GIE013635; Tue, 8 Mar 2005 15:01:16 -0500 (EST) To: Gaetano Mendola Cc: Richard Huxton , "pgsql-performance@postgresql.org" Subject: Re: bad plan In-reply-to: <422D9904.5010904@bigfoot.com> References: <422D7F23.7000109@bigfoot.com> <422D8F0E.8000906@archonet.com> <422D9904.5010904@bigfoot.com> Comments: In-reply-to Gaetano Mendola message dated "Tue, 08 Mar 2005 13:22:28 +0100" Date: Tue, 08 Mar 2005 15:01:15 -0500 Message-ID: <13634.1110312075@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/138 X-Sequence-Number: 10843 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