1、select * from A where ccdate between '2011-01-01' and '2011-12-31'--记录11000,耗时31秒
2、select * from A where ccdate between '2012-01-01' and '2012-03-31'--记录880,耗时55分钟
请问是否有什么东东锁住了between '2012-01-01' and '2012-03-31' 这段时间的数据?
...全文
206960打赏收藏
表记录被锁住,,,
1、select * from A where ccdate between '2011-01-01' and '2011-12-31'--记录11000,耗时31秒 2、select * from A where ccdate between '2012-01-01' and '2012-03-31'--记录880,耗时55分钟 请问是否有什么东东锁住了between '2012-01-01' and '2012-03-31' 这段时间的数据?
时间长了不应该数据少了,加上 with (nolock) 后分段查询下试试
1、select * from A with (nolock) where ccdate between '2011-01-01' and '2011-12-31'
2、select * from A with (nolock) where ccdate between '2012-01-01' and '2011-12-31
union all
select * from A with (nolock) where ccdate between '2011-12-31' and '2012-03-31
1、对ccdate建立索引 CREATE CLUSTERED INDEX mycol_ccdate_index ON A(ccdate)
2、查询select后面*换成较少的需要的字段试试 select col1,col2 from A where ccdate>'2012-01-01' and ccdate<='2012-03-31'