Understanding INNER JOIN versus IN subquery

From: Robert James <srobertjames(at)gmail(dot)com>
To: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Understanding INNER JOIN versus IN subquery
Date: 2009-07-20 13:37:17
Message-ID: e09785e00907200637o1d62c3cfm8776861352f9ee23@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have two queries which should be equivalent. The Planner plans them
differently, although they are both about the same time. Can someone
explain why?
select word from dict
where
word in
(select substr('moon', 0, generate_series(3,length('moon'))))

select * from dict
inner join (select substr('moon', 0, generate_series(3,length('moon')))) as
m
on dict.word = m.substr

Is one preferred?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ivan Sergio Borgonovo 2009-07-20 14:12:56 Re: Documentation Improvement suggestions
Previous Message Adrian Klaver 2009-07-20 13:36:02 Re: timestamp with time zone tutorial