INF: Indexes Use Distribution Page StatisticsID: Q75827
|
The following steps illustrate that distribution statistics are used when only a prefix of the index is used in the query.
create table t1 (c1 varchar(20), c2 varchar(20), c3 char(30) )
create index i1 on t1 (c1,c2)
The third column ensures that the table occupies enough pages to
keep the optimizer from always choosing a table scan.
select * from t1 where c1=1
select * from t1 where c1=150
Note that the first query scans the table instead of using the
index. This proves that the optimizer is aware that the index is
very unselective when c1=1. In contrast, the second query uses the
index. This indicates that the optimizer is also aware that the
index is very selective when c1=150.
Additional query words: Transact-SQL dblib
Keywords : kbprg SSrvDB_Lib SSrvTrans SSrvServer
Version : 4.2
Platform : OS/2
Issue type :
Last Reviewed: March 11, 1999