index not used with subselect in where clause ? - Mailing list pgsql-general

From Christian Fritze
Subject index not used with subselect in where clause ?
Date
Msg-id 200104161720.TAA03534@chatsubo.sprawl.de
Whole thread Raw
Responses Re: index not used with subselect in where clause ?
List 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. --



pgsql-general by date:

Previous
From: Joel Burton
Date:
Subject: Re: Possible ODBC driver error
Next
From: Stephan Szabo
Date:
Subject: Re: index not used with subselect in where clause ?