Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E8FA34760C5 for ; Sun, 25 Aug 2002 11:12:31 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 65F07475F6D for ; Sun, 25 Aug 2002 11:12:31 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id g7PFCOZM005883; Sun, 25 Aug 2002 11:12:24 -0400 (EDT) To: Manuel Sugawara Cc: pgsql-sql@postgresql.org Subject: Re: left join query does not perform well In-reply-to: References: Comments: In-reply-to Manuel Sugawara message dated "25 Aug 2002 00:20:09 -0500" Date: Sun, 25 Aug 2002 11:12:23 -0400 Message-ID: <5882.1030288343@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/339 X-Sequence-Number: 9185 Manuel Sugawara writes: > Ouch, 3117.48 msec vs. 1.15 msec is a huge difference. I need > something else? or may be postgres optimizer can't cope with > left/right joins? I think the problem is you're constraining the join order into a very inefficient one. See http://www.ca.postgresql.org/users-lounge/docs/7.2/postgres/explicit-joins.html But it's difficult to be sure, when you are showing us EXPLAIN output that manifestly doesn't correspond to what you say the queries are. For instance the nearest match to "epr_vord_grupo AS grupo" in the explain output is "epr_ord_grupo g" ... I'm also wondering if any of the tables used in the queries are really views, and if so what the view definitions are. regards, tom lane