溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Oracle Rownum分頁改寫

發布時間:2020-08-09 03:15:00 來源:ITPUB博客 閱讀:131 作者:chenoracle 欄目:關系型數據庫

Oracle Rownum分頁改寫

---說明:案例來自《   收獲,不止SQL優化》

創建測試數據:

---drop table test_rownum purge;

SQL >   create   table  test_rownum as   select   *   from  dba_objects ;

SQL >   select   count (*)   from  test_rownum ;   ---75793

SQL >   alter   session   set  statistics_level = all   ;

SQL >   set  linesize 1000

SQL >   set  pagesize 500

分頁寫法 1

SQL >   select   *   from   ( select  t. *, rownum   as  rn   from  test_rownum t )  a where  a.rn >= 1   and  a.rn <= 10 ;

查看執行計劃:

SQL >   select   *   from   table ( dbms_xplan.display_cursor ( null , null , 'allstats last' ));

Oracle Rownum分頁改寫

分頁寫法 2

SQL >   select   *   from   ( select  t. *, rownum   as  rn   from  test_rownum t where   rownum <= 10 )  a where  a.rn >= 1 ;   

查看執行計劃:

SQL >   select   *   from   table ( dbms_xplan.display_cursor ( null , null , 'allstats last' ));

Oracle Rownum分頁改寫

總結: 寫法1的buffer為1080,掃描真實數據為75793條,寫法2的buffer只有5,掃描真實數據為10條,性能較寫法1有很大改善。

歡迎關注我的微信公眾號"IT小Chen",共同學習,共同成長?。?!

Oracle Rownum分頁改寫

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女