Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


about logical reads question


about logical reads question

Author
Message
lovexueer
lovexueer
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 27
I create ths script as following:

CREATE TABLE [dbo].[t](
[id] [char](6) NOT NULL,
[b] [varchar](8000) NOT NULL,
CONSTRAINT [pk_t] PRIMARY KEY CLUSTERED
(
[id] ASC
)

insert into t values('00001',REPLICATE('A',4000) )
insert into t values('00002',REPLICATE('B',4000) )

insert into t values('000021',REPLICATE('E',4000) )

insert into t values('00003',REPLICATE('C',4000) )

insert into t values('00004',REPLICATE('D',4000) )

OK,Let's dump index internal:

dbcc ind(0,'t',1)

PageFID PagePID IAMFID IAMPID ObjectID IndexID PartitionNumber PartitionID iam_chain_type PageType IndexLevel NextPageFID NextPagePID
1 1989 NULL NULL 1609772792 1 1 72057594053459968 In-row data 10 NULL 0 0
1 1988 1 1989 1609772792 1 1 72057594053459968 In-row data 1 0 1 1994
1 1992 1 1989 1609772792 1 1 72057594053459968 In-row data 2 1 0 0
1 1993 1 1989 1609772792 1 1 72057594053459968 In-row data 1 0 0 0
1 1994 1 1989 1609772792 1 1 72057594053459968 In-row data 1 0 1 1993



Page id=1992 is a root page ,

DBCC traceon(3604)
dbcc page(0,1,1992,3)

output like this:

FileId PageId Row Level ChildFileId ChildPageId id (key) KeyHashValue
1 1992 0 1 1 1988 NULL NULL
1 1992 1 1 1 1994 00002 NULL
1 1992 2 1 1 1993 00004 NULL

my question is when I isse the following sql:

select * from t where id<='00001'

sql server report it need four logical reads.

I think it only need read index root page(pageid=1192) and the left leaf index page(pageid =1988) ,so it need only two logical reads.



who can explain it why it need four logical reads.
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47198 Visits: 44367
What showed 4 logical reads?

set statistics io on
go
select * from t where id<='00001'



Results:
Table 't'. 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.


Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search