这句SQL语句如何优化,现在执行很慢很慢......

entice 2003-08-06 12:05:01
select column_oid,value from (
select a.column_oid,a.doc_oid, c.lable value
from f_item a,f_column b,f_refitem c
Where a.column_oid = b.column_oid
and b.ref_id != -1 and b.type !=5
and b.ref_id = c.ref_oid and a.value = c.value
and (a.doc_oid = ? or doc_oid in (select doc_oid from f_document where supdoc = ? ))
Union
select a.column_oid,a.doc_oid,a.value
from f_item a,f_column b
Where a.column_oid = b.column_oid And b.ref_id = -1
and (a.doc_oid = ? or a.doc_oid
in (select doc_oid from f_document where supdoc = ? ))
)
order by doc_oid
...全文
19 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
csusmart 2003-08-06
  • 打赏
  • 举报
回复
你的索引建了没有,是怎么建的?
Michaelyfj 2003-08-06
  • 打赏
  • 举报
回复
建议不要用in,如果可以用exists来代替,尽量用exists来代替
wwl007 2003-08-06
  • 打赏
  • 举报
回复
select a.column_oid,a.doc_oid, c.lable value
from f_item a,f_column b,f_refitem c,(select doc_oid from f_document
where supdoc = ?
union
select '?' from dual) d
Where a.column_oid = b.column_oid
and b.ref_id != -1 and b.type !=5
and b.ref_id = c.ref_oid and a.value = c.value
and a.doc_oid =d.doc_iod
wwl007 2003-08-06
  • 打赏
  • 举报
回复
索引应该没有问题的 因为是对于查询出来的记录再操作
已经没有很多数据了
我感觉你的 in 语法有点问题
可能数度很慢
entice 2003-08-06
  • 打赏
  • 举报
回复
应该怎么办?请高手指点...
beckhambobo 2003-08-06
  • 打赏
  • 举报
回复
order by doc_oid打乱了索引顺序,当然慢

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧