状况是这样:
语句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.   


    --字段C做聚集索引
    --语句改成
    select a,b,c from table1 where c >='2011-02-01' and c<='2011-03-01'
      

  2.   

    用set statistics time on 看时间两次运行之前
    先运行
    dbcc dropcleanbuffers
    dbcc freeproccache
      

  3.   

    SQL code
    --字段C做聚集索引
    --语句改成
    select a,b,c from table1 where c >='2011-02-01' and c<='2011-03-01'
    试过了,也是一样的
      

  4.   

    联结了不少其他的表,表关系很多,有点复杂.不知道是不是跟这个有关,但是想不通怎么数据量少会比数据量多慢新发现:
    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秒