More efficient left join of big table

Posted by Zeus on Stack Overflow See other posts from Stack Overflow or by Zeus
Published on 2010-05-04T15:18:17Z Indexed on 2010/05/04 15:28 UTC
Read the original article Hit count: 223

Filed under:
|

Hello, I have the following (simplified) query

select P.peopleID, P.peopleName, ED.DataNumber
from peopleTable P
    left outer join (   
        select PE.peopleID, PE.DataNumber 
        from formElements FE
             inner join peopleExtra PE on PE.ElementID = FE.FormElementID 
        where FE.FormComponentID = 42
    ) ED on ED.peopleID = P.peopleID

Without the sub-query this procedure takes ~7 seconds, but with it, it takes about 3minutes.

Given that table peopleExtra is rather large, is there a more efficient way to do that join (short of restructuring the DB) ?

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server-2005