Update statement on big table

Eshwar 216 Reputation points
2023-09-11T17:28:09.5733333+00:00

HI,

This update statement is taking lot of time, the data in the staging table is ~7-10M and account table is ~1M.

Can you help what can be done to speed it up?

UPDATE STG
SET account_id = A.account_id,
	account_agency_id = A.account_agency_id,
	account_number = A.account_number
FROM ETL.Stg_data STG
INNER JOIN account A ON RTRIM(LTRIM(SUBSTRING(STG.Data, 23, 20))) = A.account_number
WHERE STG.RecordType > 30

Thanks,

Eshwar.

SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,704 questions
SQL Server | Other
{count} votes

2 answers

Sort by: Most helpful
  1. Erland Sommarskog 121.9K Reputation points MVP Volunteer Moderator
    2023-09-12T20:42:55.1833333+00:00

    The top wait is SLEEP_BPOOL_STEAL, you can read about it here: https://www.sqlskills.com/help/waits/sleep_bpool_steal/

    This suggests that you are short on memory. How much memory is there in the machine? What does sp_configure 'max server memory' say? How big are the tables in megabytes?

    0 comments No comments

  2. soumen barua 5 Reputation points
    2023-09-25T17:52:22.57+00:00

    Hi,

    Can you try following and see if it made difference:

    create clustered index c1 on stg(data)

    You will need a clustered index on that joining column to get this update working that is improve performance. Preferably both tables having clustered indices.

    Also, try to remove string functions at ON clause by using a stored procedure to do the update for better performance. Functions will cause table scan.

    Rgds.

    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.