More efficient left join of big table
- by Zeus
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) ?