MongoCursor中的Limit和BatchSize有什么区别? [英] What is the difference between Limit and BatchSize in MongoCursor?

查看:1644
本文介绍了MongoCursor中的Limit和BatchSize有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MongoDB游标对象提供了BatchSize属性Limit属性,但是我似乎找不到任何明确说明两者之间区别的权威信息.

The MongoDB cursor object provides a BatchSize property and and Limit property but I can't seem to find any definitive information that properly clarifies the difference between the two.

我正在使用.Net驱动程序,以了解它的价值.

I'm using the .Net driver, for what it's worth.

推荐答案

限制是您想要的结果总数.如果您的查询将返回一千个文档,但您只需要5个文档,则可以使用Limit来限制总结果的大小.

Limit is the total number of results you want. If your query would return one thousand documents but you only want 5 you can use Limit to limit the size of the total result.

BatchSize是每个批次应返回的结果数.如果查询的结果集很大,则MongoDB不会一批返回所有结果.它将返回总结果的子集,然后当光标需要下一批结果时,光标将向服务器发送getMore消息.

BatchSize is the number of results that should be returned in each batch. If your result set for a query is large MongoDB isn't going to return all the results in one batch. It will return a subset of the total result, then the cursor will send a getMore message to the server when it needs the next batch of results.

这篇关于MongoCursor中的Limit和BatchSize有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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