top of page
Search
Writer's picturepartition liu

‘A’ = N’A’ , will not kill index seek in sqlserver version above 2014 anymore



Thanks to



The advisor show us that we can get different behavior when we use condition , ='20000' or N'20000'


CODE

/*+++++++++++++++++*/

set nocount on

go

create table dbo.Data

(

Id int not null identity(1,1),

VarcharColumn varchar(10) not null,

Placeholder char(200) null

constraint DEF_Data_Placeholder

default 'The placeholder',

constraint PK_Data

primary key clustered(ID)

)

go


declare

@I int

select @I = 0

begin tran

while @I < 50000

begin

insert into dbo.Data(VarcharColumn)

values(convert(varchar(10),@I))

select @I += 1

end

commit

go


create unique nonclustered index IDX_Data_VarcharColumn

on dbo.Data(VarcharColumn)

go

/*+++++++++++++++++*/


In his article, He means





However, as my site enviroument ,

Microsoft SQL Server 2014 - 12.0.2000.8 (X64) Enterprise Edition (64-bit) on Windows NT 6.1

I get an different result



and



Maybe in sqlserver new version . the SQL engine enhanced.

0 views0 comments

Recent Posts

See All

Comments


bottom of page