I would try to add an index on the foreign keys in your UserSiteRight_T
table - they're not yet indexed, and an index on those fields should speed up the lookups:
CREATE NONCLUSTERED INDEX IX01_UserSiteRight
ON UserSiteRight_T(UserID_i)
CREATE NONCLUSTERED INDEX IX02_UserSiteRight
ON UserSiteRight_T(SiteID_i)
and on your SitePath_T table as well:
CREATE NONCLUSTERED INDEX IX01_SitePath
ON dbo.SitePath_T(SiteID_i)
Try to put these in place, then run your queries again, and compare the run times and the execution plans - do you see any improvement??
It's a common misconception, but SQL Server does not automatically put an index on a foreign key column (like SiteID_i
on SitePath_T
), even though the general consensus is that a foreign key is useful and potentially speeds up both enforcement of referential integrity, as well as JOINs over those foreign keys.