Why is this sub-query select so slow? - Mailing list pgsql-sql

From Kevin Sangalee
Subject Why is this sub-query select so slow?
Date
Msg-id 199908042213.WAA25108@kakapo.susa.net
Whole thread Raw
List 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 by date:

Previous
From: astromonk
Date:
Subject: sequences not reliable?
Next
From: Tom Lane
Date:
Subject: Re: [SQL] Cache lookup failed with FUNCTION + TRIGGER