Why is this sub-query select so slow?

From: Kevin Sangalee <kevin(at)susa(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Why is this sub-query select so slow?
Date: 1999-08-04 22:08:43
Message-ID: 199908042213.WAA25108@kakapo.susa.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Browse pgsql-sql by date

  From Date Subject
Next Message DE VOLDER Fabrice 1999-08-05 06:26:43 unsuscribe
Previous Message Tom Lane 1999-08-04 22:07:14 Re: [SQL] Cache lookup failed with FUNCTION + TRIGGER