状况是这样:
语句1:select a,b,c from table1 where c between '2011-01-01' and '2011-03-01'
这条语名查出来所用是时间是3秒语句2:select a,b,c from table1 where c between '2011-02-01' and '2011-03-01'
这条语名查出来所用的时间是12秒说明一下,并不只是一两次这样,每次测试都这样,搞不明白为什么时间段大的所用时间比时间段小的少.
语句1:select a,b,c from table1 where c between '2011-01-01' and '2011-03-01'
这条语名查出来所用是时间是3秒语句2:select a,b,c from table1 where c between '2011-02-01' and '2011-03-01'
这条语名查出来所用的时间是12秒说明一下,并不只是一两次这样,每次测试都这样,搞不明白为什么时间段大的所用时间比时间段小的少.
--字段C做聚集索引
--语句改成
select a,b,c from table1 where c >='2011-02-01' and c<='2011-03-01'
先运行
dbcc dropcleanbuffers
dbcc freeproccache
--字段C做聚集索引
--语句改成
select a,b,c from table1 where c >='2011-02-01' and c<='2011-03-01'
试过了,也是一样的
select a,b,c from table1 where c between '2011-01-15' and '2011-03-01' 用时12秒
select a,b,c from table1 where c between '2011-01-14' and '2011-03-01' 用时3秒