pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Arnaud Lesauvage <thewild@freesurf.fr>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-performance@postgresql.org
Subject: Re: Index on two columns not used
Date: Wed, 18 Oct 2006 19:51:07 +0200
Message-ID: <4536698B.7010001@freesurf.fr> (raw)
In-Reply-To: <28276.1161192717@sss.pgh.pa.us>
References: <45360E25.9010403@freesurf.fr>
	<28276.1161192717@sss.pgh.pa.us>

Tom Lane a écrit :
> Arnaud Lesauvage <thewild@freesurf.fr> 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



view thread (16+ messages)  latest in thread

Message-ID: <4536698B.7010001@freesurf.fr>
Permalink:  ../4536698B.7010001@freesurf.fr/
Also on:    postgresql.org/message-id/4536698B.7010001@freesurf.fr

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: thewild@freesurf.fr, tgl@sss.pgh.pa.us
  Subject: Re: Index on two columns not used
  In-Reply-To: <4536698B.7010001@freesurf.fr>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox