Why is this sub-query select so slow?

Поиск
Список
Период
Сортировка
От Kevin Sangalee
Тема Why is this sub-query select so slow?
Дата
Msg-id 199908042213.WAA25108@kakapo.susa.net
обсуждение исходный текст
Список pgsql-sql
I am querying across two tables, each of around 35000 records.

My sql is

    select * from fieldcounts where prodnum in
    (select prodnum from products where value < 150);

If I execute them individually, they return immediately. When I do an
explain, the fieldcounts is always accessed sequentially. It's accessed via
and Index Scan when I do...

    select * from fieldcounts where prodnum in (65,66,45); for example

Why doesn't postgresql use an index scan when the subselect is a query?
Any ideas gratefully appreciated.

В списке pgsql-sql по дате отправления:

Предыдущее
От: astromonk
Дата:
Сообщение: sequences not reliable?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [SQL] Cache lookup failed with FUNCTION + TRIGGER