UPDATE is taking time and causing blocking

Sam 1,476 Reputation points
2023-11-17T13:50:15.86+00:00

Hi All,

We have a below UPDATE query which is causing a lot of blocking in QA env.

This is taking more than 4 hours and keep running and we see a waittype as

"(151ms)PAGEIOLATCH_SH:QA4_ORS:3(*)". Worst part is, the app team has scheduled this stmt at multiple times of the day. Even before the 1st UPDATE completes, the same UPDATE stmt comes up with a different sessionid? No idea why they are doing so but resulting in lot of heavy blocking. I want to check if they can first archive old data and then perform the UPDATE. but sooner or later as the data gets increased we get back to same problem.

The server has 8 cpu's. 128GB RAM and max server memory set to 105 GB.

This is a history table. There is no PRIMARY KEY on this table. Its a HEAP.

The table size is 74GB and it has 34,866,803 rows. Its a wide table with 90+ columns.

Please let me know if there is any better way to re-write this below query.

Attaching table structure, index details and Estimated plan.

indexes

SQL stmt

===========

UPDATE C_B_REF_IND_HIST

server settings

indexes

1-HEAP or clustered idx

update_frm

TableStructure.txt

Regards,

Sam

SQL Server | Other
{count} votes

Answer accepted by question author
  1. Dan Guzman 9,411 Reputation points
    2023-11-18T12:06:01.32+00:00

    In addition to, creating a non-clustered index on first_nm column, is there a way to make it run faster? can it done in small chunks ?

    The non-clustered index on name is a good first step to avoid the full table scan and mitigate blocking. I suggest you create that index and monitor.

    For next steps, consider changing one of the other indexes to clustered. If index key values are unique, explicitly specify unique as that can help SQL Server optimize queries better. Same with non-clustered indexes. The best candidate for the clustered index depends on the workload and queries.


0 additional answers

Sort by: Most helpful

Your answer

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