Indexes and subqueries

From: Anton de Wet <adw(at)obsidian(dot)co(dot)za>
To: pgsql-general(at)postgresql(dot)org
Subject: Indexes and subqueries
Date: 1999-03-07 09:04:03
Message-ID: Pine.LNX.4.04.9903071103300.28957-100000@ra.obsidian.co.za
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


I'm using 6.4.2 and I have the same problem as noted in previous mails in
the list archives but I can't find a coherent answer to the problem.

I need:

select * from sometable
where somefield in (select anotherfield from anothertable)

if I do:

select * from sometable where somefield in ('a','b','c');

explain uses the indexes i have created on sometable.somefield, when I use
the subquery a linear search is done.

Up till now I have handeled this by running the subquery in perl or tcl
and creating the quoted list and this works fine. However, now I have a
case where the query created in this way is longer than the 8192 bytes
allowed.

Now I need one of 2 solutions:

1) Is there any way I can let the subquery use the index?

or

2) How difficult/safe is it to change the max query length?

Your help will he HIGHLY appreciated!

Anton

--------------------------------------------------------------------
"And I'm told we [geeks and suits] do share some common rituals. Our
'flame war' is apparently held in person in their land and
called 'project meeting'." --- Alan Cox

Browse pgsql-general by date

  From Date Subject
Next Message Anatoly K. Lasareff 1999-03-07 09:56:05 Re: [ADMIN] date & time
Previous Message Ralf Weidemann 1999-03-07 05:40:22 servlet problem