简体   繁体   English

分页大量数据

[英]Paginate large amount of data

Something is very common results of a search, for example, paging, and is usually shown the total page, results, etc ... 有些东西是搜索的常见结果,例如分页,通常会显示总页数,结果等...

Two examples: 两个例子:

Google - https://www.google.com.br/?gfe_rd=cr&ei=h4PzVLy3JMiU8QeE3ICYBQ&gws_rd=ssl#safe=off&q=test - approximately 2.67 billion results (0.39 seconds) Google - https://www.google.com.br/?gfe_rd=cr&ei=h4PzVLy3JMiU8QeE3ICYBQ&gws_rd=ssl#safe=off&q=test - 约26.7亿条结果(0.39秒)

Stackoverflow - https://stackoverflow.com/search?q=test - 1,561,211 results Stackoverflow - https://stackoverflow.com/search?q=test - 1,561,211结果

For example, Google, assumes that these 2.67 billion results are found by the database to be counted. 例如,Google假设数据库中找到了这些26.7亿个结果。 As is done to count the total results of a query with many results without compromising performance? 正如在不影响性能的情况下计算具有多个结果的查询的总结果一样? What magic is this? 这有什么神奇之处?

"approximately 2.67 billion results (0.39 seconds)" -- Notice the word "approximately". “约26.7亿个结果(0.39秒)” - 注意“大约”一词。 That opens the door wide open to tricks that allow it to do the count in virtually 0.00 seconds. 这打开了大门,让它在几乎0.00秒内完成计数。 Examples: 例子:

  • Do some counts every night 每晚做一些计数
  • Statistically sample 统计样本
  • Have summary tables 有汇总表

"1,561,211 results", on the other hand 'sounds' like an exact count. “1,561,211结果”,另一方面'听起来'就像一个确切的计数。 But it may be a "stale" result. 但这可能是一个“陈旧”的结果。 I refreshed that page a few times; 我刷新了那几页; the value did not change. 价值没有改变。 This leads me to believe that they really count it, but then cache the result for some time. 这让我相信他们真的算了,但随后将结果缓存了一段时间。 Memcached is a likely suspect for such caching. Memcached可能是这种缓存的嫌疑人。

(There are doubtless other tricks of the trade.) (毫无疑问,这笔交易还有其他技巧。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM