Quantcast
Channel: Forum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15889

MAX always shows INDEX SCAN instead of INDEX SEEK ?

$
0
0

Hi guys,

I am confused, why MAX always shows INDEX SCAN instead of INDEX SEEK ?

use tempdb
go
--drop table tb_001
create table tb_001(id int primary key,rv [timestamp] not null)
GO
declare @i int = 1
while @i<20000
begin
    insert into tb_001(id) select @i
    set @i+=1
    waitfor delay '00:00:00.001'
end
GO
create index ix_rv on tb_001(rv)

set statistics io on

select MAX(rv) from tb_001 -- it shows index scan ,why not index seek ?
--Table 'tb_001'. Scan count 1, logical reads 2, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

if it was really index scan ,it should show many logical reads instead of 2 , could anyboday explain this and help me out ?

Any help would be appreciated.

Thanks & Regards
nicofer




Viewing all articles
Browse latest Browse all 15889

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>