求教一个奇葩的sql优化问题,急急急急!

qq_38322353 2017-04-14 02:44:01
select trandate, serseqno, acctno, voukind,vouno, memomsg, cdflag, amount, trancode, oppaccno, oppacctname, flag
from glsinacctlist a
where cancelflag='0'
and trancode not in ( '548300', 'T00000' ) and acctno='6217000088103047' and trandate='2017-04-17'
and ( ( (trancode = 'TC0001' or trancode = 'TP0001') and ( flag = '1' or flag = '2' ) ) or (trancode <> 'TC0001' and trancode <> 'TP0001' and flag not in ('B','C','D','E') ) )
and not exists ( select 1 from GLSINACCTLIST where acctno=a.acctno and trandate=a.trandate and cancelstan=a.serseqno and cancelflag='1') order by a.serseqno

这条语句在执行时,有的时候很快,有的时候很慢,一执行cpu就飚到100%
表glsinacctlist 中大概有8000万条数据
求大神门给个优化建议,最好能解释下为什么,在下小白啊,下周上线
急急急急!
...全文
355 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
落落叶叶无声 2017-04-14
  • 打赏
  • 举报
回复
select trandate, serseqno, acctno, voukind,vouno, memomsg, cdflag, amount, trancode, oppaccno, oppacctname, flag from glsinacctlist a not exists ( select 1 from GLSINACCTLIST where acctno=a.acctno and trandate=a.trandate and cancelstan=a.serseqno and cancelflag='1') 这个连接的意义是什么,不能直接换成cancelflag!='1'么
卖水果的net 2017-04-14
  • 打赏
  • 举报
回复
执行上看着,没什么异常。 收集一下两张表的统计信息吧。
qq_38322353 2017-04-14
  • 打赏
  • 举报
回复


这是执行计划,请大家帮帮忙,谢谢大家了
qq_38322353 2017-04-14
  • 打赏
  • 举报
回复
引用 1 楼 wmxcn2000 的回复:
看一下执行计划吧,估计计算量比较大
额。。。看不太懂执行计划啊,怎么看啊大神
卖水果的net 2017-04-14
  • 打赏
  • 举报
回复
看一下执行计划吧,估计计算量比较大

3,499

社区成员

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

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