在所有MSSQL 的脚本前面加上 set nocount on  可以关闭消息反馈机制,减少网络流量(用于BS模式) 特别是反馈消息比较多的情况下。

 

DateDiff去分析多语句的时间(用于批数据查询,且在同一个Go块中,如果在不同Go块中,但在同一个session中,就要用临时表。)

 

判断执行计划中是seek(搜索操作)还是scan(扫描操作)?(seek操作性能要好于scan操作的性能)

 

连接查询比子查询效率高

查看查关信息的语句:

SET statistics io on

SET statistics  time   on

SET showplan_text  on

SET showplan_all  on (用这个查出来的,主要看预计IO  和预计 CPU 时间 ,还有看是否走索引,并是否是Seek方式 )

如果是做存在性查询:

IF EXISTS(select  A.id from  Base_Attachment as A where  ((A.[EntityFullName] = ''  + @SourceType  + '') and (A.[EntityID] = @SourceID)))

比select   @cnt=count(A.id) from  Base_Attachment as A where …要快好多。

源自:

相关文章:

  • 2022-12-23
  • 2021-07-09
  • 2021-11-17
猜你喜欢
  • 2021-07-31
  • 2021-09-18
  • 2021-08-26
  • 2021-06-30
  • 2022-12-23
  • 2022-02-25
  • 2022-12-23
相关资源
相似解决方案