我這裏查詢時超過30分鐘。告訴我如何讓它更快?我應該如何優化1分鐘?如何使我的查詢速度更快
SELECT DISTINCT b.BLDGID AS 'CBRE Building Id',
e.CLIENTCODE AS 'DEXUS Building Id',
b.BLDGNAME AS 'Building Name',
cmgr.RMGRNAME AS 'Snr Manager AS',
cmgr.RMGREMAIL AS 'Snr Manager AS Email',
cmigr.IMGRNAME AS 'Manager AS',
cmigr.IMGREMAIL AS 'Manager AS Email',
ttj.JOBID AS 'TSR No',
ttj.JobType,
wws.JobActivity,
wrj.[Description] AS 'JobActivity Sub-Category',
ttj.JobDetail AS 'TSR Details',
wc.contname AS 'Tenant Contact',
wc.Name AS 'Tenant Company NAME',
wc.ContName AS 'Tenant Contact',
wc.Phone AS 'Tenant Phone',
wc.Mobile AS 'Tenant Mobile',
wc.Email AS 'Tenant Email',
TS.Q_Id,
TA.Answer
FROM BLDG b
JOIN dbo.ENTITY e ON e.ENTITYID = b.ENTITYID
JOIN dbo.CBRERMGR cmgr ON cmgr.RMGRID = e.RMGRID
JOIN dbo.CBREIMGR cmigr ON cmigr.USERID = cmgr.USERID
JOIN WSM_AUNZ..wsm_Ref_Buildings wsmbldg ON wsmbldg.BLDGID = b.BLDGID
JOIN WSM_AUNZ..TSP_TSR_Job ttj ON ttj.BuildingID = wsmbldg.BuildingId
JOIN WSM_AUNZ..wsm_WorkOrderSchedule wws ON wws.BuildingID = wsmbldg.BuildingId
JOIN WSM_AUNZ..wsm_Ref_JobActivityAction wrj ON wrj.JobActivityActionID = wws.JobActivityActionID
JOIN WSM_AUNZ..wsm_contact wc ON wc.BuildingID = ttj.BuildingID
JOIN WSM_AUNZ..wsm_TSRSurveyAnswer TA ON TA.JobId = ttj.JobID --AND WSM_AUNZ.dbo.wsm_TSRSurveyAnswer.clientId = wsmbldg.CLIENTID
JOIN WSM_AUNZ..wsm_TSRSurvey TS ON TS.Q_Id = TA.Q_Id
JOIN LOCA l ON e.LOCAID = l.LOCAID
AND l.LOCADESC LIKE 'DEX%'
AND b.INACTIVE <> 'Y'
請張貼執行計劃https://www.simple-talk.com/sql/performance/execution-plan-basics/ – StanislavL