Joins versus subqueries

  • Jesper, query would still be the same regardless which query run first.

     

    Remi, the issue is about joins vs subqueries. It is about utilizing "the best" query in JOINs and compare that against "the best" query using subqueries. So using NOT IN is not appropriate here.

     

    Regards,

     

     

     

  • I thought that maybe the performance difference had something to do with caching. Now I have executed each query 1000 times, and the "not exists" query is definitely faster - about 2 seconds vs. 3 seconds for 1000 executions.

  • I think that is a very good and underestimated point sara. 

    Personally I veer heavily towards the subquery route.  My general rule of thumb, unless encountering severe performance issues is that If the only reason I'm refering to the table is criteria related, then it's a sub-query.  I only Join the table when columns from that table are required in the result set. 

     

Viewing 3 posts - 16 through 17 (of 17 total)

You must be logged in to reply to this topic. Login to reply