Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道是否有人知道是否可以使用这样的查询来查询 _id 字段:
{$lte : ObjectId(....) , $gte : ObjectId(...)
, 代替
{$in : [ObjectId( )...lots of ObjectId.....]}
如果性能有所提高(我认为是这样..)
谢谢
是的,有这样的查询 {_id : {$lte : ObjectId(....) , $gte : ObjectId(...)} }
性能取决于您在第一个查询中选择的范围。较小的范围意味着快速响应。对于第二个查询,响应取决于查询中 ObjectIds 的计数和范围。ObjectIds 值中的更多碎片可能会导致大量页面错误。