Different ways to speed up an update statement?

chrisrdba 386 Reputation points
2024-09-04T22:23:36.38+00:00

Hello. I'm trying to figure out an outside the box way to speed up the update statement at the bottom of this. It's in a warehouse type of DB and runs several times a day. In non-Prod I've brought it down to 6 minutes (from 8) with some good indexing, but was hoping for something more clever that will get it down further or even eliminate the need for it along the lines of persisted computed column , indexed view, filtered index, etc but keep running in to one problem or the other, depending on what exactly Im attempting.

Any ideas?

update a
set a.amrepidorig=a.amrepid
from db.schema.table a with (nolock)
	join db.schema.table b with (nolock)
		on a.id=b.id and b.isOriginal=1
where isnull(a.amrepidorig,1)<>b.amrepid and b.amrepid is not null

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,671 questions
{count} votes

1 answer

Sort by: Most helpful
  1. LiHongMSFT-4306 26,706 Reputation points
    2024-09-05T02:19:16.4066667+00:00

    Hi @chrisrdba

    Some tips:

    • Be careful with the query hints. Sometimes they may cause more unexpected side effects.
    • Avoid using functions on indexed column. Functions or expressions on indexed columns can prevent the use of indexes.
    • Check if it is the slow disk I/O issue.
    • Analyze the execution plan for more details.

    Best regards,

    Cosmog


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.