SQL query 效能调整(陆续整理)

工作中遇到的一些状况
1.下group by 的效能比下distinct 好 (MSSQL 2000)
2.linkserver 用exec open query,效能比用select 好
3.先捞到#tmp 再来运算 e.g.select * into #tmp from table where date=20190101
4.用变数比较慢
select * from table where col1=123
会比以下写法来的快(但还不知为什么
declare @val int =123
select * from table where col1=@val

5.加with (nolock)比较不受update影响
6.建索引
7.把table依年份切成多个table

--------------------------------其它网路上看到的,感受不明显
用= 不要用>= /like (全文scan)
不要用子查询(用join 取代)
少做栏位类型转换



关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章