Good morning,
Here is the select query that is running for long time
SELECT TE.JobID,TotalDistanceTravelled as Distance,--convert(varchar(30),TotalFare) as TotalFare, TotalTripFare AS TotalFare FROM [sqlcdscluster\sqlcds].cdsbusiness.dbo.Tbljobbooking MW WITH(NOLOCK) INNER JOIN dbo.tbltripenddetail TE WITH(NOLOCK) ON MW.JobID=TE.jobID AND DATEDIFF(HOUR,TripEndTime,Getdate())<=1 AND TripendStatus =0 AND TE.JOBID!=0 INNER JOIN [sqlcdscluster\sqlcds].cdsbusiness.dbo.tblCitrusSendingDetails CS WITH(NOLOCK) ON TE.JobID=CS.JobID AND ( ( (CS.Response IS NOT NULL AND CS.Response!='') AND DATEDIFF(MINUTE,TripEndTime,Getdate())<=20 ) OR DATEDIFF(MINUTE,TripEndTime,Getdate())>21 ) ORDER BY TE.JobID DESCActually, we cannot use OPENQUERY instead of linked server because we will be migrating to amazon cloud and our architect instructed us not to replace linked server with OPENQUERY.
Here is the actual execution plan:
Please help if there are other ways to tune this query.
B.Chaitanya Kiran