Received: from sss.pgh.pa.us ([192.204.191.242]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f5II7oa10243; Mon, 18 Jun 2001 14:07:50 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.4/8.11.4) with ESMTP id f5II7c307465; Mon, 18 Jun 2001 14:07:38 -0400 (EDT) To: The Hermit Hacker cc: pgsql-sql@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: LEFT JOIN ... In-reply-to: References: Comments: In-reply-to The Hermit Hacker message dated "Mon, 18 Jun 2001 14:26:18 -0300" Date: Mon, 18 Jun 2001 14:07:38 -0400 Message-ID: <7462.992887658@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200106/262 X-Sequence-Number: 3523 The Hermit Hacker writes: > FROM note_links nl, notes n LEFT JOIN calendar c ON (n.nid = c.nid) > WHERE (n.type = 'A' OR n.type = 'N' OR n.type = 'H' OR n.type = 'C') > AND (nl.id = 15748 AND contact_lvl = 'company') > AND n.nid = nl.nid > ORDER BY start DESC; > Is there some way to write the above so that it evaluates: > first, so that it only has to do the LEFT JOIN on the *one* n.nid that is > returned, instead of the 86736 that are in the table? Try adding ... AND n.nid = 15748 ... to the WHERE. It's not very bright about making that sort of transitive-equality deduction for itself... regards, tom lane