Yes. When comparing a variable or column of type MAX, the internal code uses the semantics of the stream. Types of variables less than 8000 in length use the direct comparison semantics. A simple example:
create table A (k int, x varchar(8000)); create clustered index cdxA on A(k); go insert into A (k, x) select number, name from master..spt_values; go declare @s datetime = getutcdate(), @i int = 0; set nocount on; while(@i < 100000) begin declare @x varchar(8000); select @x = x from A where k = 1 and x = 'rpc'; set @i = @i + 1; end select datediff(ms, @s, getutcdate());
Performing this repeatedly gives the measured cycle time 2786, 2746, 2746, 2900, 2623, 2736, so the average value is about 2.7 s.
The same code, but replaced the two varchar (8000) inputs with varchar (max), gives the measured times 4916, 5203, 5280, 5040, 5543, 5130, the average time 5.2s is much higher, -max.
The conclusion is that in very tight loops, varchar (max) compares and assigns more slowly compared to non-max types. Like all optimizations, it should be considered and applied only after a thorough measurement, which shows that this is a bottleneck.
Please note that the difference is visible even according to the actual length of 3 characters and is not obtained from differences in storage.