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) ?
More details:
The inner part of the sub-query, e.g.
select PE.peopleID, PE.DataNumber
from formElements FE
inner join peopleExtra PE on PE.ElementID = FE.FormElementID
where FE.FormComponentID = 42
Takes between <1 and 5 seconds to execute, and returns 95k rows
There are 1500 entries in the peopleTable.