Re: [SQL] LEFT JOIN ... - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [SQL] LEFT JOIN ...
Date
Msg-id 7462.992887658@sss.pgh.pa.us
Whole thread Raw
In response to LEFT JOIN ...  (The Hermit Hacker <scrappy@hub.org>)
Responses Re: [SQL] LEFT JOIN ...
List pgsql-hackers
The Hermit Hacker <scrappy@hub.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


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: (Really) Re: [PATCH] inet << indexability
Next
From: Bruce Momjian
Date:
Subject: Re: plperl direction