Oracle paging SQL statement

Source: Internet
Author: User

1. Minute by rowid
Select * From t_xiaoxi where rowid in (select rid from (select rownum RN, rid from (select rowid RID, CID from

T_xiaoxi order by cid desc) Where rownum <10000) Where rn> 9980) order by cid desc;
Execution time: 0.03 seconds
2. Score by Analysis Function
Select * from (select T. *, row_number () over (order by cid desc) rk from t_xiaoxi t) Where rk <10000 and rk> 9980;
Execution time: 1.01 seconds
3. Divide by rownum
Select * from (select T. *, rownum rn from (select * From t_xiaoxi order by cid desc) t where rownum <10000) Where

Rn> 9980; execution time: 0.1 seconds
Here, t_xiaoxi is the table name, CID is the table's key field, and the records 9981-9999 are sorted by CID in descending order. The t_xiaoxi table has more than 70000 records.
Personal perception 1 is the best, followed by 3, and 2 is the worst.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.