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 006F33A46A0 for ; Mon, 1 Nov 2004 22:08:33 +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 86659-10 for ; Mon, 1 Nov 2004 22:08:30 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 383453A469C for ; Mon, 1 Nov 2004 22:08:31 +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 iA1M8SXd027482; Mon, 1 Nov 2004 17:08:28 -0500 (EST) To: Alvaro Nunes Melo Cc: Pgsql-Performance Subject: Re: Performance difference when using views In-reply-to: <1099345230.8204.30.camel@localhost> References: <1099345230.8204.30.camel@localhost> Comments: In-reply-to Alvaro Nunes Melo message dated "Mon, 01 Nov 2004 19:40:30 -0200" Date: Mon, 01 Nov 2004 17:08:28 -0500 Message-ID: <27481.1099346908@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/10 X-Sequence-Number: 8964 Alvaro Nunes Melo writes: > I have some views that are used to make some queries simplest. But when > I use them there is a performance loss, because the query don't use > indexes anymore. Below I'm sending the query with and without the view, > its execution times, explains and the view's body. It's not the same query, because you are implicitly changing the order of the LEFT JOINs when you group some of them into a subquery (view). Join order is significant for outer joins ... regards, tom lane