新聞中心
Oracle Rownum分頁(yè)改寫(xiě)
專(zhuān)注于為中小企業(yè)提供成都網(wǎng)站制作、做網(wǎng)站服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)港南免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了上1000家企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過(guò)網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。
---說(shuō)明:案例來(lái)自《 收獲,不止SQL優(yōu)化》
創(chuàng)建測(cè)試數(shù)據(jù):
---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
分頁(yè)寫(xiě)法 1 :
SQL > select * from ( select t. *, rownum as rn from test_rownum t ) a where a.rn >= 1 and a.rn <= 10 ;
查看執(zhí)行計(jì)劃:
SQL > select * from table ( dbms_xplan.display_cursor ( null , null , 'allstats last' ));
分頁(yè)寫(xiě)法 2 :
SQL > select * from ( select t. *, rownum as rn from test_rownum t where rownum <= 10 ) a where a.rn >= 1 ;
查看執(zhí)行計(jì)劃:
SQL > select * from table ( dbms_xplan.display_cursor ( null , null , 'allstats last' ));
總結(jié): 寫(xiě)法1的buffer為1080,掃描真實(shí)數(shù)據(jù)為75793條,寫(xiě)法2的buffer只有5,掃描真實(shí)數(shù)據(jù)為10條,性能較寫(xiě)法1有很大改善。
歡迎關(guān)注我的微信公眾號(hào)"IT小Chen",共同學(xué)習(xí),共同成長(zhǎng)!??!
標(biāo)題名稱(chēng):OracleRownum分頁(yè)改寫(xiě)
本文路徑:http://fisionsoft.com.cn/article/pdgdgs.html