Speed of paged queries in Oracle

后端 未结 4 1611
死守一世寂寞
死守一世寂寞 2020-12-14 12:27

This is a never-ending topic for me and I\'m wondering if I might be overlooking something. Essentially I use two types of SQL statements in an application:

  1. Re
4条回答
  •  盖世英雄少女心
    2020-12-14 13:02

    You might want to trace the query that takes a lot of time and look at its explain plan. Most likely the performance bottleneck comes from the TOTAL_ROWS calculation. Oracle has to read all the data, even if you only fetch one row, this is a common problem that all RDBMS face with this type of query. No implementation of TOTAL_ROWS will get around that.

    The radical way to speed up this type of query is to forego the TOTAL_ROWS calculation. Just display that there are additional pages. Do your users really need to know that they can page through 52486 pages? An estimation may be sufficient. That's another solution, implemented by google search for example: estimate the number of pages instead of actually counting them.

    Designing an accurate and efficient estimation algorithm might not be trivial.

提交回复
热议问题