X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 019FCD1E948 for ; Wed, 31 Mar 2004 23:50:02 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 50252-09 for ; Wed, 31 Mar 2004 19:50:00 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 7EE46D1E914 for ; Wed, 31 Mar 2004 19:49:58 -0400 (AST) Received: from [63.195.55.98] (HELO 192.168.1.29) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 4742888; Wed, 31 Mar 2004 15:51:21 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Manuel Sugawara , pgsql-sql@postgresql.org Subject: Re: left join on a view takes significantly more time. Date: Wed, 31 Mar 2004 15:49:29 -0800 User-Agent: KMail/1.5.4 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200403311549.29211.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/276 X-Sequence-Number: 17375 Manuel, > I'm facing a wired problem. When I left join two tables PostgreSQL is > able to do it fast using the corresponding indices, However, if I > define a simple view (to format the data) on one of the tables, the > left join does not use the indices. Is something wrong here? At a guess, the complex CASE statements are causing the planner to behave badly. What happens if you do a straight join and not a left join? Also, it's generally a good idea to put your join expression in the same order as the referenced tables. You confused me and you could confuse the planner at some stage. -- -Josh Berkus Aglio Database Solutions San Francisco