sql优化细节

一张表

至少有createtime  updatetime creater updater  valid  软删除

返回多条数据时 用 WITH(NOLOCK)

Order by ,distinct 非常消耗性能,不可以随便使用

尽量考虑top(n) 

in 不超过100

不可以用子查询, 子查询只能嵌套一次

链表查询 ,不要查询字段里 查询其他table 

金钱用decimate 精度会丢失 可以使用 int long varchar

排序的查询条件尽量建索引

update 尽量精准到一条或两三条记录。

发布了47 篇原创文章 · 获赞 10 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_34233080/article/details/103078972