Re: Index not used in query. Why?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Andrei Bintintan" <klodoma(at)ar-sd(dot)net>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Index not used in query. Why?
Date: 2004-10-19 16:52:49
Message-ID: 16865.1098204769@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

"Andrei Bintintan" <klodoma(at)ar-sd(dot)net> writes:
> Hi to all! I have the following query. The execution time is very big, it
> doesn't use the indexes and I don't understand why...

Indexes are not necessarily the best way to do a large join.

> If I use the following query the indexes are used:

The key reason this wins seems to be that the id_status = 4 condition
is far more selective than id_status > 3 (the estimates are 52 and 36967
rows respectively ... is that accurate?) which means that the second
query is inherently about 1/700th as much work. This, and not the use
of indexes, is the fundamental reason why it's faster.

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Contact AR-SD.NET 2004-10-19 17:49:45 Re: Index not used in query. Why?
Previous Message Andrei Bintintan 2004-10-19 16:26:49 Index not used in query. Why?