Nabil Sayegh <nsmail@sayegh.de> writes:
> Although the two queries should be equivalent the second takes about 4s
> and the first takes almost 2 MINUTES.
It's impossible to say anything intelligent about this with only the
text of the queries to go on. What indexes do you have on these tables?
What does EXPLAIN show as the query plan for each query?
Oh, and have you done a VACUUM ANALYZE recently on these tables?
regards, tom lane