如何提高一下语句的效率SQL语句如下,我用的是ORACLE 10G: select a.name, b.Code EntCode, b.Name EntlName, from WF_Flow a, WF_Model b where a.EntGid = '2000000000000000000000000009087A' and b.EntGid = '200000000000
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 03:50:28
如何提高一下语句的效率SQL语句如下,我用的是ORACLE 10G: select a.name, b.Code EntCode, b.Name EntlName, from WF_Flow a, WF_Model b where a.EntGid = '2000000000000000000000000009087A' and b.EntGid = '200000000000
如何提高一下语句的效率
SQL语句如下,我用的是ORACLE 10G:
select a.name,
b.Code EntCode,
b.Name EntlName,
from WF_Flow a, WF_Model b
where a.EntGid = '2000000000000000000000000009087A'
and b.EntGid = '2000000000000000000000000009087A'
and a.ModelGid = b.ModelGid
and a.FlowGid in (select FlowGid
from v_WF_Task
where EntGid = '2000000000000000000000000009087A'
and ExecGid = 'D855240574B5422FA2E15CAE9C3AB561'
and Stat in (0, 1, 2, 3, 4, 5)
union
select '' from dual)
Order By a.CreateDate Desc
我改成如下形式:
select a.name,
b.Code EntCode,
b.Name EntlName,
from WF_Flow a, WF_Model b
where a.EntGid = '2000000000000000000000000009087A'
and b.EntGid = '2000000000000000000000000009087A'
and a.ModelGid = b.ModelGid
and exists (select 1
from C
where EntGid = '2000000000000000000000000009087A'
and ExecGid = 'D855240574B5422FA2E15CAE9C3AB561'
and Stat in (0, 1, 2, 3, 4, 5)
and flowgid=a.flowgid)
Order By a.CreateDate Desc
这样效率反而不如上面的In,其中WF_Flow大概3W条记录,WF_Model大概10条记录,C表大概10W条记录,请高手指点,谢谢
Exists不是比in效率的吗?怎么会出现以上情况,非常不解
如何提高一下语句的效率SQL语句如下,我用的是ORACLE 10G: select a.name, b.Code EntCode, b.Name EntlName, from WF_Flow a, WF_Model b where a.EntGid = '2000000000000000000000000009087A' and b.EntGid = '200000000000
v_WF_Task 你这个好像是个视图吧?
你执行一下select FlowGid
from v_WF_Task
where EntGid = '2000000000000000000000000009087A'
and ExecGid = 'D855240574B5422FA2E15CAE9C3AB561'
and Stat in (0,1,2,3,4,5)
看看效率怎么样
-----------补充-------
in和exists效率问题你看下边这个