Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id EB1089FA4AD for ; Wed, 18 Oct 2006 14:32:16 -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 31367-06-2 for ; Wed, 18 Oct 2006 17:32:01 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 93A899FB336 for ; Wed, 18 Oct 2006 14:31:59 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k9IHVve6028277; Wed, 18 Oct 2006 13:31:57 -0400 (EDT) To: Arnaud Lesauvage cc: pgsql-performance@postgresql.org Subject: Re: Index on two columns not used In-reply-to: <45360E25.9010403@freesurf.fr> References: <45360E25.9010403@freesurf.fr> Comments: In-reply-to Arnaud Lesauvage message dated "Wed, 18 Oct 2006 13:21:09 +0200" Date: Wed, 18 Oct 2006 13:31:57 -0400 Message-ID: <28276.1161192717@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200610/362 X-Sequence-Number: 21491 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 ... regards, tom lane