sql语句优化问题

zhlsyc 2009-05-26 03:18:41
select * from mycontract where serialno in (select distinct relativeno from app_relative_back union select distinct relativeno from conn_relative_back)

如何将上面的语句改成性能比较好的sql语句,除了将in 改为exists之外,还有其他好的方法没,表mycontract 和其他两张表的数据都比较大,都在100万以上,mycontract 表数据较其它两个稍大些,请高手指教
...全文
34 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhlsyc 2009-05-26
  • 打赏
  • 举报
回复
谢谢!不知道distinct这个为什么比较占资源呢
范佩西_11 2009-05-26
  • 打赏
  • 举报
回复
主要是distinct这个占资源。
改成下面的试下:
select *
from mycontract a
where exists
(select 1from from app_relative_back where relativeno = a.serialno)
union
select *
from mycontract b
where exists
(select 1from from conn_relative_back where relativeno = b.serialno)

3,491

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 高级技术相关讨论专区
社区管理员
  • 高级技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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