如何优化SQL查询 [英] How to optimize SQL Query

查看:78
本文介绍了如何优化SQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,
我想优化以下代码

Hello Friends,
I wanted to optimize following code

inner join tbl_planning P on p.iterationid=(select MAX(iterationid) from tbl_iteration  where mechanicalid = B.mechanicalid
and iterationid< B.iterationid and artworktype in (2,5)) 
OR (
p.mechanicalid = ISNULL((select MAX(iterationid) from tbl_iteration  where mechanicalid = B.mechanicalid
and iterationid< B.iterationid),
(select mechanicalid from tbl_mechanicalbrief MF where MF.mechanicalid=b.mechanicalid)) and jobtype=1)



有什么想法可以优化此联接吗?

在此先感谢



Any idea to optimize this join?

Thanks in advance

推荐答案

1. 在Top& amp; amp;使用
的botton零件
1. Max aggrigate is used in both Top & botton parts using
select MAX(iterationid) from tbl_iteration  where mechanicalid = B.mechanicalid
and iterationid< B.iterationid)



尝试解决此问题并分开保存



Try to resolve this and hold seperatly


这篇关于如何优化SQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆