I have inherited a poorly designed Access 2002 database. I am trying to troubleshoot a few queries, and one query in particular has left me scratching my head. It is nesting several joins to the same table… each join is nested in the previous join rather than just joining to the same table multiple times. I honestly can’t even say for sure why this query works – I have never seen a join created this way… Can anyone comment on the effect of these inner joins (performance wise?) and will I see a performance improvement by un-nesting them?
Example:
--Detals cut
FROM tempMapIDs INNER JOIN
(BenefitMapRiders AS RxDeduct INNER JOIN
(BenefitMapRiders AS SubAbuse INNER JOIN
(BenefitMapRiders AS Infertility INNER JOIN
(BenefitMapRiders AS Dental INNER JOIN
(BenefitMapRiders AS Chiro INNER JOIN
(BenefitMapRiders AS Vision INNER JOIN
(BenefitMapRiders AS Drug INNER JOIN qryOptionsMap ON Drug.NewRiderOption = qryOptionsMap.Drug)
ON Vision.NewRiderOption = qryOptionsMap.Vision)
ON Chiro.NewRiderOption = qryOptionsMap.Chiro)
ON Dental.NewRiderOption = qryOptionsMap.Dental)
ON Infertility.NewRiderOption = qryOptionsMap.Infertility)
ON SubAbuse.NewRiderOption = qryOptionsMap.SubAbuse)
ON RxDeduct.NewRiderOption = qryOptionsMap.RxDeduct)
ON (tempMapIDs.NewDate = qryOptionsMap.RenewalDate)
AND (tempMapIDs.NewPlanOption = qryOptionsMap.PlanOption)
AND (tempMapIDs.RxDeduct = RxDeduct.OldRiderOption)
AND (tempMapIDs.SubAbuse = SubAbuse.OldRiderOption)
AND (tempMapIDs.Infertility = Infertility.OldRiderOption)
AND (tempMapIDs.Chiro = Chiro.OldRiderOption)
AND (tempMapIDs.Vision = Vision.OldRiderOption)
AND (tempMapIDs.Dental = Dental.OldRiderOption)
AND (tempMapIDs.Drug = Drug.OldRiderOption)
AND (tempMapIDs.MapID = RxDeduct.MapID)
AND (tempMapIDs.MapID = SubAbuse.MapID)
AND (tempMapIDs.MapID = Infertility.MapID)
AND (tempMapIDs.MapID = Chiro.MapID)
AND (tempMapIDs.MapID = Vision.MapID)
AND (tempMapIDs.MapID = Dental.MapID)
AND (tempMapIDs.MapID = Drug.MapID)
)
That is just the way Access tends to write queries when you use the visual query designer to create them. It shouldn’t perform any worse than the equivalent syntax you are used to.
Create a new query with 2 or three joins using the visual designer and you will see the same syntax.