-1

我有这个在 SQL Server 中运行非常慢的查询。请建议对其进行优化以更快地运行。

  • TABLE_A有 100'000'000 行
  • TABLE_B有 1'000'000 行

ID两个表在,Modify_DateSource列上都有非聚集索引。

询问:

Insert into TABLE_A       
  select * from RABLE_B B
  Where NOT Exists (Select 1 
                    From TABLE_A A
                    Where B.ID = A.ID
                      And B.Modify_Date = A.Modify_Date
                      And B.Source = A.Source)
4

1 回答 1

4
INSERT  INTO TABLE_A
        SELECT  B.*
        FROM    TABLE_B B
                LEFT JOIN TABLE_A A ON B.ID = A.ID
                                   AND B.Modify_Date = A.Modify_Date
                                   AND B.Source = A.Source
        WHERE   A.ID IS NULL
于 2013-10-10T12:15:11.510 回答