Performance of SQL Server 2005 Query

前端 未结 3 2023
余生分开走
余生分开走 2020-11-30 14:35

-------------------- this takes 4 secs to execute (with 2000 000 rows) WHY?---------------------

DECLARE @AccountId INT 
DECLARE @Max INT 
DECLARE @MailingLi         


        
3条回答
  •  日久生厌
    2020-11-30 15:12

    One possible item to check is whether the MailingListId and AccountId fields in the tables are of type INT. If, for example, the types are BIGINT, the query optimizer will often not use the index on those fields. When you explicitly define the values instead of using variables, the values are implicitly converted to the proper type.

    Make sure the types match.

提交回复
热议问题