Re: Index not used in query. Why? - Mailing list pgsql-performance

From Tom Lane
Subject Re: Index not used in query. Why?
Date
Msg-id 16865.1098204769@sss.pgh.pa.us
Whole thread Raw
In response to Index not used in query. Why?  ("Andrei Bintintan" <klodoma@ar-sd.net>)
List pgsql-performance
"Andrei Bintintan" <klodoma@ar-sd.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

pgsql-performance by date:

Previous
From: "Andrei Bintintan"
Date:
Subject: Index not used in query. Why?
Next
From: Max Baker
Date:
Subject: Re: Vacuum takes a really long time, vacuum full required