oracle 分页效率sql

  方法一:

 SELECT PROCLOG_ID FROM (
  SELECT t.PROCLOG_ID, row_number() OVER (ORDER BY t.PROCLOG_ID DESC) AS rnum
  FROM tab_proclog_nso t
  JOIN tab_proclog_oper oper
  ON t.oper_id=oper.oper_id
  where oper.TYPE='NSO')
  WHERE RNUM BETWEEN 1 AND 10;

 

方法二:

select
    t.PROCLOG_ID,to_char(t.STARTTIME,'YYYY-MM-DD HH24:MI:SS') STARTTIME,t.FULLOPERATION,t.FULLRESULT
    from (select rownum rownum2, b.*
            from (select * from tab_proclog_nso nso
  JOIN tab_proclog_oper oper
  ON nso.oper_id=oper.oper_id
  where oper.TYPE='NSO'
            ORDER BY PROCLOG_ID DESC) b
           where rownum <= 10 ) t
   where t.rownum2 > 0

 

都说row_number()效率高,这两个方法经过测试,性能是一样的。数据量都是百万级的。  在未建索引的情况下,查询都很慢,将近30秒。 

 

大家还有更有效率的查询方法么????

你可能感兴趣的:(oracle 分页效率sql)