Received: from tera.jprc.com (TERA.JPRC.COM [207.86.147.221]) by hub.org (8.8.8/8.7.5) with SMTP id PAA04282 for ; Wed, 24 Jun 1998 15:31:12 -0400 (EDT) Received: from HUGO.JPRC.COM (HUGO.JPRC.COM [207.86.147.218]) by tera.jprc.com (NTMail 3.03.0017/1.agyw) with ESMTP id za181063 for ; Wed, 24 Jun 1998 15:33:44 -0400 Message-ID: <002101bd9fa6$21f035e0$da9356cf@hugo.jprc.com> From: "Peter Su" To: Subject: beginner join optimization question Date: Wed, 24 Jun 1998 15:27:31 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 4.72.2106.4 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4 I have two tables, say, t1 (id, title) t2 (id, hash) I want to run a query of the form: select title from t1,t2 where t1.id=t2.id and t2.hash=15; I have indexes on all fields, but postgres insists on doing a nested loop join between t1 and t2 which takes a lot of time. If I do this select title into temp from t1,t2 where t1.id=t2.id; select * from temp where temp.hash=15; things go much much faster because now postgres uses a hash join. Is there any way to synthesize this behavior without using the temp. table? thanks, Pete p.s. t1 has, say, 10K records and t2 is somewhat smaller, less then a thousand records.