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 664EA529A3 for ; Wed, 6 Jul 2005 18:54:12 -0300 (ADT) 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 91316-01 for ; Wed, 6 Jul 2005 21:54:11 +0000 (GMT) Received: from netbox.unitech.com.ar (unknown [200.32.92.34]) by svr1.postgresql.org (Postfix) with ESMTP id F1E1752995 for ; Wed, 6 Jul 2005 18:54:07 -0300 (ADT) Received: from dariop (dariop.unitech.com.ar [192.168.1.237]) by netbox.unitech.com.ar (8.11.6/8.11.6) with ESMTP id j66MtfE28801 for ; Wed, 6 Jul 2005 18:55:41 -0400 Received: from 127.0.0.1 (AVG SMTP 7.0.323 [267.8.9]); Wed, 06 Jul 2005 18:54:02 -0300 From: "Dario Pudlo" To: Subject: join and query planner Date: Wed, 6 Jul 2005 18:54:02 -0300 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4952.2800 In-Reply-To: Importance: Normal X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200507/111 X-Sequence-Number: 13352 (first at all, sorry for my english) Hi. - Does "left join" restrict the order in which the planner must join tables? I've read about join, but i'm not sure about left join... - If so: Can I avoid this behavior? I mean, make the planner resolve the query, using statistics (uniqueness, data distribution) rather than join order. My query looks like: SELECT ... FROM a, b, LEFT JOIN c ON (c.key = a.key) LEFT JOIN d on (d.key=a.key) WHERE (a.key = b.key) AND (b.column <= 100) b.column has a lot better selectivity, but planner insist on resolve first c.key = a.key. Of course, I could rewrite something like: SELECT ... FROM (SELECT ... FROM a,b LEFT JOIN d on (d.key=a.key) WHERE (b.column <= 100) ) as aa LEFT JOIN c ON (c.key = aa.key) but this is query is constructed by an application with a "multicolumn" filter. It's dynamic. It means that a user could choose to look for "c.column = 1000". And also, combinations of filters. So, I need the planner to choose the best plan... I've already change statistics, I clustered tables with cluster, ran vacuum analyze, changed work_mem, shared_buffers... Greetings. TIA.