分页查询结果集 [英] Paging of Query Result Set

查看:99
本文介绍了分页查询结果集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Greetings Overflowers

Greetings Overflowers,

我想知道是否有一种查询某种数据库的方法,并且只在完整的结果集中获取一个窗口,

I'm wondering if there is a way to query some kind of a database and only fetch a certain window in the full result set without having to actually go through them all.

例如,如果我查询我的数据库,而我想只有结果数100到200,数据库会获取所有的结果到1000),匹配我的查询,以后过滤它们以排除我指定的窗口框架之外的任何东西?

For example, if I query my database and I want only results number 100 to 200, would the database fetch all the results (say 0 to 1000) that match my query and later on filter them to exclude any thing outside my specified window frame ?

实际上,我正在处理一个全文搜索问题不是真正的关系数据库的东西)。

Actually, I'm working on a full text search problem (not really relational db stuff).

那么如何对谷歌和其他搜索引擎,他们得到完整的结果,然后过滤,或者他们有直接访问只需要的窗口框架?

So how about Google and other search engines, do they get full result then filter or do they have direct access to only the needed window frame ?

谢谢大家!

推荐答案


  • 对于数据库(传统的,关系型的),执行的查询包含多个where 子句,这将导致数据库引擎限制返回的结果数。因此,如果您指定一个基本限制主键的2个值之间的where子句,

  • For a database (traditional, relational), a query that is executed contains a number of "where" clauses, which will cause the database engine to limit the number of results that it returns. So if you specify a where clause that basically limits between 2 values of the primary key,

select * from table where id> 99 and id <

select * From table where id>99 and id<201;

您将得到您要求的信息。

you'll get what you're asking for.


  • 对于搜索引擎,您为获取结果而进行的查询将始终分页 - 使用各种技术,所有结果将被预分为多页,一些将被缓存。其他页面将根据需要生成。所以如果你想要页面100-200,那么你只能获取那些需要的。

筛选选项效率不高,因为大型数据源不会将所有数据加载到内存和切片中 - 以加载所需的内容。

The option to filter is not very efficient because large data sources never want to load all their data into memory and slice - you only want to load what's needed.

这篇关于分页查询结果集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆