Quantcast
Channel: Getting started with SQL Server forum
Viewing all articles
Browse latest Browse all 9243

Newbie to optimization

$
0
0

I tried the following test using 'SET STATISTICS IO ON' using an indexed table, then the same command with no index different table, but identical.  Index is as follows: (the table has 6467155 rows)

CREATE  INDEX [OrderID_ind] ON [dbo].[OrdDetails]([OrderID]) ON [PRIMARY]
GO

Then I ran these statements:

SET STATISTICS IO ON -- Has identity column w/index
select * from OrdDetails
SET STATISTICS IO off
GO

SET STATISTICS IO ON -- Has no indexes
select * from OrdDetOpt
SET STATISTICS IO OFF

The results can back as is:

Table 'OrdDetails'. Scan count 1, logical reads 27999, physical reads 1, read-ahead reads 25218.

Table 'OrdDetOpt'. Scan count 1, logical reads 27998, physical reads 0, read-ahead reads 27998.

why doesn't the indexed table have better statistics and it has to scan the entire table even though there is an indexed identity column?

Also, I couldn't find the DBCC command to flush memory before running these.

thx,

Kat


Viewing all articles
Browse latest Browse all 9243


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