Index not used on single select, but used in join. - Mailing list pgsql-novice

From Francisco Reyes
Subject Index not used on single select, but used in join.
Date
Msg-id 20011107145446.X27009-100000@zoraida.natserv.net
Whole thread Raw
Responses Re: Index not used on single select, but used in join.
List pgsql-novice
I have a table, hraces,  with a column called "horse" and an index
"lower(horse)".

If I try:
explain select horse from hraces where lower(horse) = 'little irish nut';

The query doesn't use the index. It says it would do a sequential scan.

I have another table, tmp, which also has a horse column.

If I do:
explain select  hr.horse from hraces hr, tmp where lower(hr.horse) =
lower(tmp.horse);

The explain says it would do a sequential in tmp and use the index on
hraces. This makes perfect sense since hraces has close to 8 million records
and tmp has less than 300 records.

What I can't understand is why doing the select against hraces alone
doesn't use the index. If I do the select without the 'explain' it does
find the 84 records on hraces for 'little irish nut'.




pgsql-novice by date:

Previous
From: Francisco Reyes
Date:
Subject: Re: Getting info on index
Next
From: Tom Lane
Date:
Subject: Re: IS NULL