I am attempting a SQL query of some ax tables:
Select PET.TransId
FROM dbo.PROJEMPLTRANS AS PET
JOIN dbo.HCMWORKER AS hw
ON hw.RECID = pet.WORKER
JOIN dbo.PROJTABLE AS PT
ON pt.PROJID = PET.PROJID
AND pt.DATAAREAID = pet.DATAAREAID
JOIN dbo.PROJINVOICETABLE AS pit
ON pit.PROJINVOICEPROJID = pt.PROJINVOICEPROJID
AND pit.DATAAREAID = pt.DATAAREAID
WHERE PET.TRANSDATE between '2018-11-12' and '2019-02-10'
If I take out the HCMWORKER join OR the PROJINVOICETABLE join, the query runs about 95,000 records in 3 seconds.
Once I have both HCMWORKER and PROJINVOICETABLE in together, it takes 30+ minutes. I can't seem to understand why either of those joins would cause such an increase in execution time.
*This post is locked for comments