Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 695A89FB33B for ; Wed, 18 Oct 2006 14:51:12 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 37475-04 for ; Wed, 18 Oct 2006 17:51:07 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id C84329FB2CC for ; Wed, 18 Oct 2006 14:51:07 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from outmx002.isp.belgacom.be (outmx002.isp.belgacom.be [195.238.5.52]) by svr4.postgresql.org (Postfix) with ESMTP id 114635AF9E8 for ; Wed, 18 Oct 2006 17:51:06 +0000 (GMT) Received: from outmx002.isp.belgacom.be (localhost [127.0.0.1]) by outmx002.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-OUT-2.22) with ESMTP id k9IHp2rj001310 for ; Wed, 18 Oct 2006 19:51:02 +0200 (envelope-from ) Received: from [127.0.0.1] (68.158-201-80.adsl-dyn.isp.belgacom.be [80.201.158.68]) by outmx002.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-OUT-2.22) with ESMTP id k9IHot1k001228; Wed, 18 Oct 2006 19:50:55 +0200 (envelope-from ) Message-ID: <4536698B.7010001@freesurf.fr> Date: Wed, 18 Oct 2006 19:51:07 +0200 From: Arnaud Lesauvage User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) MIME-Version: 1.0 To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Re: Index on two columns not used References: <45360E25.9010403@freesurf.fr> <28276.1161192717@sss.pgh.pa.us> In-Reply-To: <28276.1161192717@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Antivirus: avast! (VPS 0642-2, 18/10/2006), Outbound message X-Antivirus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.2 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE X-Spam-Level: X-Archive-Number: 200610/363 X-Sequence-Number: 21492 Tom Lane a écrit : > Arnaud Lesauvage writes: >> When I join these two tables, the 2-column index of the first table is >> not used. >> Why does the query planner think that this plan is better ? > > Hm, is gid by itself nearly unique in these tables? If so, the merge > join would get only marginally more efficient by using both columns as > merge conditions. Heikki's probably right to guess that the planner > thinks it's better to use the smaller index. > > However, if there are lots of duplicate gids, then it ought to have > preferred the two-column merge ... gid is the primary key of the first table, so absolutely unique. Thanks for the information Tom ! -- Arnaud