Oracle 优化效率

Posted 魑魅丶魍魉

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle 优化效率相关的知识,希望对你有一定的参考价值。

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 优化效率的主要内容,如果未能解决你的问题,请参考以下文章

oracle笔记--DML语句优化

VsCode 代码片段-提升研发效率

ORACLE使用WITH AS和HINT MATERIALIZE优化SQL解决FILTER效率低下

数据库优化

sql Oracle代码片段

简析Oracle性能优化可能出现的问题