首页 > 数据库技术 > 详细

Oracle 优化效率

时间:2018-07-25 11:07:36      阅读:159      评论:0      收藏:0      [点我收藏+]

1、rownum

(1)

较慢
SELECT ywlsdm, qybm, spzt, czsj, czrydm FROM GH_hs 
WHERE ywlsdm in (SELECT ywlsdm FROM GH_hs WHERE spzt = 2)
较快
SELECT ywlsdm, qybm, spzt, czsj, czrydm FROM GH_hs WHERE ywlsdm in (SELECT ywlsdm FROM GH_hs WHERE spzt = 2 and rownum <= (SELECT COUNT(*) FROM GH_hs hs WHERE EXISTS (SELECT ywlsdm FROM GH_hs WHERE spzt = 2)))

2、with as 临时表

select * from (
with 
qybm as (
select gx.qybm
          from (select a.ghdm
                   from gh_ghdm a
                  start with a.ghdm = 1
                 connect by prior a.ghdm = a.sjghdm) gh
         inner join gh_qyghgx gx on gh.ghdm = gx.tjghdm
         
),
yg as (
   select * from gh_jc_yg t where t.yglx = 0
)
select yg.* from qybm , yg where qybm.qybm = yg.qyghdm 
)

 

Oracle 优化效率

原文:https://www.cnblogs.com/ssbydk/p/9364480.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!