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 1A08430E5CD for ; Thu, 12 Jun 2003 05:52:44 +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 96337-02 for ; Thu, 12 Jun 2003 02:52:08 -0300 (ADT) Received: from unimm.unisoftbg.com (mail.unisoftbg.com [194.12.229.207]) by svr1.postgresql.org (Postfix) with ESMTP id 31FEF30E5BA for ; Thu, 12 Jun 2003 02:51:54 -0300 (ADT) Received: (qmail 22920 invoked by uid 507); 12 Jun 2003 05:55:17 -0000 Received: from unknown (HELO t1.unisoftbg.com) (pginfo%t1.unisoftbg.com@194.12.229.193) by 0 with SMTP; 12 Jun 2003 05:55:17 -0000 Message-ID: <3EE8061B.1FAED8AD@t1.unisoftbg.com> Date: Thu, 12 Jun 2003 06:48:27 +0200 From: pginfo X-Mailer: Mozilla 4.03 [en] (Win95; I) MIME-Version: 1.0 To: Tom Lane Cc: "pgsql-performance@postgresql.org" Subject: Re: left join performance problem References: <3EE74C2D.88390062@t1.unisoftbg.com> <26068.1055386671@sss.pgh.pa.us> Content-Type: multipart/alternative; boundary="------------18E76A8EC6AEFB84026890A9" X-Archive-Number: 200306/54 X-Sequence-Number: 2138 --------------18E76A8EC6AEFB84026890A9 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Many thanks Tom, the doc do not contain solution for this case, but the idea to change the join order was excelent and all is working fine at the moment. regards, ivan. Tom Lane wrote: > 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 --------------18E76A8EC6AEFB84026890A9 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit Many thanks Tom,
the doc do not contain solution for this case, but the idea to
change the join order was excelent and all is working fine at the moment.

regards,
ivan.

Tom Lane wrote:

pginfo <pginfo@t1.unisoftbg.com> 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

  --------------18E76A8EC6AEFB84026890A9--