MS SQL Perofrmance issue with T-sql

Please find the screenshot and suggest us how to fine tune: This is SQL Server 2016
Key.jpg
VijayAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Daniel_PLDB Expert/ArchitectCommented:
Hi,

You didn't provide us with the query. Basing on this screen only you are querying columns which are not included in an index and index has been choosen, therefore even if it has clusterd index key values in its leafs SQL is looking to PK for other columns.
Modify your index accordingly by adding columns (main or included - depends on query which we don't see) or create new covering index if query is worth doing that - is being frequently executed etc.

Regards,
Daniel
0
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Please tell us on what basis you believe we can answer your question without seeing the code that generated it, the schemas of the queried tables, or a full execution plan:   Mind reading, Seance, or 'The Force'.
0
VijayAuthor Commented:
----This is the Query---

WITH [CTEOrderedUpdate]
		  AS
		  (
			SELECT TOP(@MaxRows)
			  [Uid],
			  [AgentName],
			  [Step],
			  [StepInProgress],
			  [ProcessCount],
			  [DateStarted],
			  [DateFinished]
			FROM
			  [dbo].[BlobMigrationQueue] WITH(ROWLOCK, UPDLOCK, READPAST,Index=IX_BlobMigrationQueueGet)
			WHERE
			  [Step] = 0 AND
			  [Failed] = 0 AND
			  [StepInProgress] = 0
		  )
		  UPDATE
			[CTEOrderedUpdate]
		  SET
			[StepInProgress]  = 1,
			[AgentName]         = @AgentName,
			[ProcessCount]    = [ProcessCount] + 1,
			[DateStarted]     = SYSDATETIME(),
			[DateFinished]    = NULL
		  OUTPUT
			inserted.[Uid]
		  INTO
			@Batch([Uid])

Open in new window

0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

Pawan KumarDatabase ExpertCommented:
How much time the query is taking ?

The query is using an index but that index does not cover all the column the query needs so the query will have to go for that extra column using keylookup 50001 times which looks like an issue. If possible add(include) that extra column in that in that index itself so that we can ignore this key lookup part. Meaning we will get all the data at one place and do not have to traverse to get the additional data.

Also why we are specifying so many locks and an Index..(forced)
 [dbo].[BlobMigrationQueue] WITH(ROWLOCK, UPDLOCK, READPAST,Index=IX_BlobMigrationQueueGet)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
VijayAuthor Commented:
Thank you
0
VijayAuthor Commented:
Thank you Pawan.
We found the solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SQL

From novice to tech pro — start learning today.