Oracle's paging method

  1. 1. According to ROWID to divide <! --more-->  
  2.    
  3. select * from t_xiaoxi where rowid in(select rid from (select rownum rn,ridfrom(select rowid rid,cid from   
  4. t_xiaoxi  orderby cid descwhere rownum<10000) where rn>9980)orderby cid desc;     
  5.    
  6. select * from t_xiaoxi where rowid in(select rid from (select rownum rn,ridfrom(select rowid rid,cid from  
  7. t_xiaoxi  orderby cid descwhere rownum<10000) where rn>9980)orderby cid desc;    
  8.    
  9. Execution time 0.03 seconds  
  10. 2. According to the analysis function  
  11.    
  12. select * from (select t.*,row_number() over(orderby cid desc) rk from t_xiaoxit) where rk<10000 and rk>9980;    
  13.    
  14. select * from (select t.*,row_number() over(orderby cid desc) rk from t_xiaoxit) where rk<10000 and rk>9980;   
  15.    
  16. Execution time 1.01 seconds  
  17. 3. Divided by ROWNUM  
  18.    
  19. select * from(select t.*,rownum rn from(select * from t_xiaoxi orderby ciddesc) t where rownum<10000) where    
  20. rn>9980;   
  21.    
  22. select * from(select t.*,rownum rn from(select * from t_xiaoxi orderby ciddesc) t where rownum<10000) where   
  23. rn>9980;  
  24.    
  25. Execution time 0.1 seconds  
  26. Where t_xiaoxi is the table name, cid is the key field of the table, take the 9981-9999th records sorted by CID in descending order, there are more than 70,000 records in the t_xiaoxi table  
  27. Personally, I feel that 1 is the best, 3 is the second, and 2 is the worst    

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326965498&siteId=291194637