如何提高一下语句的效率

来源:百度知道 编辑:UC知道 时间:2024/09/21 17:32:30
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 = '20000000000000000000000

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效率问题你看下边这个
http://hi.baidu.com/gefforey520/blog/item/e1dcca1e71cde9164134171b.html