X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id E8ED330E70D for ; Thu, 12 Jun 2003 02:58:02 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 31722-01 for ; Wed, 11 Jun 2003 23:57:52 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id E9E4F30E65A for ; Wed, 11 Jun 2003 23:57:51 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h5C2vpU6026069; Wed, 11 Jun 2003 22:57:52 -0400 (EDT) To: pginfo Cc: "pgsql-performance@postgresql.org" Subject: Re: left join performance problem In-reply-to: <3EE74C2D.88390062@t1.unisoftbg.com> References: <3EE74C2D.88390062@t1.unisoftbg.com> Comments: In-reply-to pginfo message dated "Wed, 11 Jun 2003 17:35:10 +0200" Date: Wed, 11 Jun 2003 22:57:51 -0400 Message-ID: <26068.1055386671@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200306/53 X-Sequence-Number: 2137 pginfo writes: > I have a big problem with pg left join performance. I think the problem is that the LEFT JOIN clause is forcing the planner to join A_SKLAD to A_MESKLAD before anything else, whereas a good plan would do some of the other joins first to eliminate as many rows as possible. You will need to revise the query to let the LEFT JOIN happen later. For discussion see http://www.postgresql.org/docs/view.php?version=7.3&idoc=0&file=explicit-joins.html regards, tom lane