index not used with subselect in where clause ?

From: Christian Fritze <The(dot)Finn(at)sprawl(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: index not used with subselect in where clause ?
Date: 2001-04-16 17:20:50
Message-ID: 200104161720.TAA03534@chatsubo.sprawl.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Good evening (GMT+0200) everybody...

I have a table with an indexed integer attribute used to
determine which rows to fetch from my data base.
(pgsql version is 7.1RC4)

When doing a

SELECT attr1 FROM table1 WHERE attr1 IN (<list of ints>)
AND <more conditions>;

where <list of ints> is entered explicitly (or generated by a
program) everything works fine and fast using the index on attr1.

But when I try doing a

SELECT attr1 FROM table1 WHERE attr1 IN (<SUBSELECT returning list of ints>)
AND <more conditions>;

then the SELECT on table1 uses a sequential scan running 'endlessly'.

Is this really how it's meant to be?

If so, why?
If not, how can I get the second version working???

Thanks in advance...
Christian

--
"The sky above the port was the color of television,
tuned to a dead channel."
-- W.G. --

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2001-04-16 17:32:18 Re: index not used with subselect in where clause ?
Previous Message Joel Burton 2001-04-16 16:36:40 Re: Possible ODBC driver error