已有的系统业务数据属性多,表之间关系紧密。单表数据量(5481 row(s) affected)级别(其中三四个主表),其他表数据量较小。

0)使用set statistics生成辅助信息参考。

实践SQLServer Tuning_搜索
set statistics io on
set statistics time on
set statistics profile on


set statistics io off
set statistics time off
set statistics profile off
实践SQLServer Tuning_搜索

1)使用Include Actual Execution plan & Include Client Statistics做参考。

实践SQLServer Tuning_hive_03

2) 短路表达式的面向业务优化:

  or表达式常用的搜索条件置前。

@cls_date_start is null and @cls_date_end is null)
                or (@cls_date_start is not null and @cls_date_end is null and expct_cls_dt >= @cls_date_start)
                or (@cls_date_start is null and @cls_date_end is not null and expct_cls_dt <= @cls_date_end)
                or (@cls_date_start is not null and @cls_date_end is not null and expct_cls_dt between @cls_date_start and @cls_date_end)

3) 针对执行计划的分析。

http://www.blogjava.net/jiabao/archive/2008/04/08/191595.html 这篇文章Mark一下,浅显又深入。

4) 对临时表添加cluster index与unique index。以让其为连接所用并避免较大表的table scan。貌似效果不错。