Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

Long running select query

$
0
0

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 DESC
Actually, 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


Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>