Re: Question about index usage

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Guido Neitzer <guido(dot)neitzer(at)pharmaline(dot)de>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Question about index usage
Date: 2006-03-07 15:04:38
Message-ID: 18453.1141743878@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Guido Neitzer <guido(dot)neitzer(at)pharmaline(dot)de> writes:
> Is there a reason why this query:
> select id from dga_dienstleister where plz in ('45257', '45259');
> doesn't use this index:
> "dga_dienstleister_plz_index" btree (plz varchar_pattern_ops)
> but uses this index:
> "dga_dienstleister_plz_index2" btree (plz)

Because IN means "=", which is a member of the index opclass for the
second index but not the first.

Why do you care? Should be about the same result either way.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Guido Neitzer 2006-03-07 15:22:38 Re: Question about index usage
Previous Message Russ Brown 2006-03-07 14:59:20 Re: Benchmark-Comparison PostGreSQL vs. SQL Server