Subselects and Indices

From: Andre Schubert <andre(dot)schubert(at)kabeljournal(dot)de>
To: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Subselects and Indices
Date: 2002-01-21 14:03:47
Message-ID: 3C4C1FC3.1EDD1034@kabeljournal.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi,

i have a simple question on indices and subselects.
Lets say i have a table foo with a column id int8 as primary_key bar.
If i do a

select * from foo where id = 10 then the index bar is used.

if i do
select * from foo where id in (10,20) then the index is used.

but if id do
select * from foo where id in ( select 10 ) then the index is not used.

Can anyone explain me this. It is very important, because i have to do
this subselect.

thanks, as

Browse pgsql-admin by date

  From Date Subject
Next Message Ferdinand Smit 2002-01-21 15:43:48 Re: Character problems
Previous Message Bruce Momjian 2002-01-21 13:33:04 Re: Performance