Any ideas why non-unique IX_UpdateDate used rather than unique Primary Key PK_MyTable ? (Or would it not make any difference?)CREATE TABLE [dbo].[MyTable]( [MyUpdateDate] [datetime] NOT NULL, [MyStatus] [tinyint] NULL, [MyPKey] [varchar](17) COLLATE Latin1_General_CI_AS NOT NULL, ... 153 other columns ... CONSTRAINT [PK_MyTable] PRIMARY KEY CLUSTERED ( [MyPKey] ASC ))CREATE NONCLUSTERED INDEX [IX_UpdateDate] ON [dbo].[MyTable] ( [MyUpdateDate] ASC)CREATE TABLE ##MyTempTable( [MyPKey] varchar(17) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, ... 157 other columns ... PRIMARY KEY ( MyPKey ))INSERT INTO ##MyTempTable ... 1,567,783 rows ...INSERT dbo.MyTableSELECT [MyUpdateDate] = GetDate(), [MyStatus] = 1, S.*FROM ##MyTempTable AS SWHERE NOT EXISTS ( SELECT * FROM dbo.MyTable AS D WHERE S.MyPKey = D.MyPKey COLLATE SQL_Latin1_General_CP1_CI_AS )ORDER BY S.MyPKey
NOTE: All the rows already exist, so there are NO actual insertionsQuery Plan:|--Clustered Index Insert(OBJECT:([MyDB].[dbo].[MyTable].[PK_MyTable]), OBJECT:([MyDB].[dbo].[MyTable].[IX_UpdateDate]), SET:([MyDB].[dbo].[MyTable].[MyUpdateDate] = RaiseIfNullInsert([Expr1008]),[MyDB].[dbo].[MyTable].[MyStatus] = [Expr1010], [MyDB].[dbo].[MyTable].[MyPKey] = [tempdb].[dbo].[##MyTempTable].[MyPKey] as [S].[MyPKey],...|--Compute Scalar(DEFINE:([Expr1008]=getdate(), [Expr1010]=CONVERT_IMPLICIT(tinyint,(1),0))) |--Top(ROWCOUNT est 0) |--Sort(ORDER BY:([S].[MyPKey] ASC)) |--Hash Match(Right Anti Semi Join, HASH:([Expr1013])=([Expr1012]), RESIDUAL:([Expr1012]=[Expr1013])) |--Hash Match(Aggregate, HASH:([Expr1013]), RESIDUAL:([Expr1013] = [Expr1013])) | |--Compute Scalar(DEFINE:([Expr1013]=CONVERT(varchar(17),[MyDB].[dbo].[MyTable].[MyPKey] as [D].[MyPKey],0))) | |--Index Scan(OBJECT:([MyDB].[dbo].[MyTable].[IX_UpdateDate] AS [D])) |--Compute Scalar(DEFINE:([Expr1012]=CONVERT_IMPLICIT(varchar(17),[tempdb].[dbo].[##MyTempTable].[MyPKey] as [S].[MyPKey],0))) |--Clustered Index Scan(OBJECT:([tempdb].[dbo].[##MyTempTable] AS [S]))