Share via

update small data is slow performance ?

ahmed salah 3,216 Reputation points
2022-02-24T07:56:45.633+00:00

i work on sql server 2019 i face issue
when make update it take 20 second for 162 rows only
so how to enhance that please

Update FT SET
 ft.ValueName=avo.name
FROM #package FT 
inner join  parts.Nop_PackageAttribute PA   with(nolock)on PA.PackageID=ft.PackageID and PA.[Key]=FT.ZfeatureId 
inner join  Nop_AcceptedValuesOption AVO with(nolock) ON convert(varchar(20),AVO.AcceptedValuesOptionID)=PA.Value 
where FT.AcceptedValueID is not null

execution plan as below

https://www.brentozar.com/pastetheplan/?id=H1jdK3Veq

table

create table #package
(
id int PRIMARY KEY IDENTITY(1,1),
ZfeatureId INT NULL,
AcceptedValueID INT NULL,
PackageID INT NULL,
ValueName NVARCHAR(2000) default ''
)
Developer technologies | Transact-SQL
Developer technologies | Transact-SQL

A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.

SQL Server | Other
SQL Server | Other

Additional SQL Server features and topics not covered by specific categories


3 answers

Sort by: Most helpful
  1. Seeya Xi-MSFT 16,756 Reputation points
    2022-02-25T10:09:07.78+00:00

    Hi @ahmed salah ,

    Please read this article about many common sign meanings in execution plan:
    https://www.red-gate.com/simple-talk/databases/sql-server/performance-sql-server/graphical-execution-plans-for-simple-sql-queries/
    In your execution plan, the number of hash match is high, which sometimes indicates:
    a missing or incorrect index
    a missing WHERE clause

    In addition, you should pay attention to update warning in your execution plan and Erland give his suggestion.
    Then you can check the new execution plan.

    Best regards,
    Seeya


    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".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?

    0 comments No comments

  2. Erland Sommarskog 134.7K Reputation points MVP Volunteer Moderator
    2022-02-24T23:03:07.35+00:00

    You could try changing:

    ``
    convert(varchar(20),AVO.AcceptedValuesOptionID)=PA.Value

    to
    

    AVO.AcceptedValuesOptionID = try_convert(int, PA.Value)

    But even better you may want to review the overall table design. This kind of type conversions are a very good recipe for bad performance.
    

    Was this answer helpful?

    0 comments No comments

  3. Olaf Helper 47,621 Reputation points
    2022-02-24T12:52:39.96+00:00

    Review the execution plan, there are at least 2 scans and an expensive hash match; and this because of missing suitable indexes.

    Was this answer 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.