"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