简体   繁体   English

在网页中使用分页是否真的对性能有任何好处?

[英]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.

相关问题 在休眠标准中使用readOnly是否有任何性能优势? - Is there any performance benefit by using readOnly in hibernate criteria? 在构造多个字符串时使用 StringBuilder 有什么显着的性能优势吗? - Is there any significant performance benefit to using StringBuilder when constructing multiple strings? 使用jsoup处理网页中的分页 - Dealing with pagination in web pages while using jsoup 使用CompletableFuture回调对性能有好处吗? - Is there a performance benefit of using CompletableFuture callbacks? 网页中的分页视图 - Pagination view in web pages Java正则表达式提供了任何性能优势? - Java regular expression offers any performance benefit? 在简单的静态方法查询中,PreparedStatement 有什么性能优势? - Any performance benefit to PreparedStatement in simple, static method query? 新的SimpleDateFormat(“ Pattern”)与applyPattern(“ Pattern”)的区别和性能优势(如果有)? - new SimpleDateFormat(“Pattern”) vs applyPattern(“Pattern”) difference and performance benefit if any? 在带有awt的Java中使用Sprite Sheet有什么好处? - Is there any benefit to using sprite sheets in Java with awt? 使用APR和Tomcat有什么好处(如果有的话)? - What is the benefit (if any) of using APR with Tomcat?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM