Re: LEFT JOIN ...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: The Hermit Hacker <scrappy(at)hub(dot)org>
Cc: pgsql-sql(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: LEFT JOIN ...
Date: 2001-06-18 18:07:38
Message-ID: 7462.992887658@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

The Hermit Hacker <scrappy(at)hub(dot)org> 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2001-06-18 18:14:00 Re: (Really) Re: [PATCH] inet << indexability
Previous Message Joe Conway 2001-06-18 18:04:49 Re: AW: Re: [SQL] behavior of ' = NULL' vs. MySQL vs. Stand ards

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2001-06-18 18:18:49 Re: LEFT JOIN ...
Previous Message Bruce Momjian 2001-06-18 17:42:05 Re: casts and conversions