Index not used on single select, but used in join.

Поиск
Список
Период
Сортировка
От Francisco Reyes
Тема Index not used on single select, but used in join.
Дата
Msg-id 20011107145446.X27009-100000@zoraida.natserv.net
обсуждение исходный текст
Ответы Re: Index not used on single select, but used in join.  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: Francisco Reyes
Дата:
Сообщение: Re: Getting info on index
Следующее
От: Tom Lane
Дата:
Сообщение: Re: IS NULL