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