[英]Is there really any performance benefit in using pagination in web pages?
I'm programming a website in Java using struts as framework, and I tried to use pagination to break a query who could take too long to return, using a query similar to this: 我正在使用struts作为框架在Java中对网站进行编程,并且我尝试使用分页来中断查询,而该查询可能需要很长时间才能返回,并使用类似于以下的查询:
select col
from ( select col,rownum AS rn from table )
where rn >= 1
and rn <=10
That is from what I've seen the stardard way for doing pagination, but I don't see any performance improvement over just select the entire table and paginate in Java only, as for Oracle to calculate the rownum
, it has to execute my query once. 这是从我见过的执行分页的标准方法得出的,但是我发现仅选择整个表并仅在Java中进行分页就不会带来任何性能改进,因为Oracle要计算rownum
,它必须执行我的查询一旦。
Ideally I want to only search for a subset of this table results, instead of searching the whole table and then discarding part of the results. 理想情况下,我只想搜索此表结果的子集,而不是搜索整个表,然后丢弃部分结果。 Is there a way for doing that? 有办法吗? Because if not, I can't see why lazy pagination would be better then just load the whole list and then separate in Java. 因为如果没有,我看不出为什么延迟分页会更好,那么只需加载整个列表然后在Java中进行分隔即可。
There is, but you won't see it until you have enough data to simulate a fully grown database. 有,但是直到您有足够的数据来模拟完全扩展的数据库后,您才能看到它。
As others mentioned in the comments, generate a few million rows into your table, and then start using pagination and watch the plan of your query. 就像其他评论中提到的那样,在表中生成几百万行, 然后开始使用分页并观察查询计划。 Now you have something that has the smell of real-life, that you can compare to caching the table in memory. 现在您有了一种具有真实感的东西,可以与将表缓存在内存中进行比较。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.