mongodb范围在两个值之间查询 - 重复字段与两个字段上的两个运算符
我只是对MongoDB查询语言有一个疑问。我有一个包含大量地理空间和时间序列数据的数据存储,我正在尝试查询一个时间范围内的记录。
如果我试图在两个值之间搜索具有$ GTE和$ LTE运算符的两个值的记录。
考虑以下两个查询:
查询#1-指定字段两次
{"RecivedTime": {$gte: 1000000}, "ReceivedTime": {$lte: 2000000}}
查询#2-我刚刚在同一字段上的两个运算符
{"ReceivedTime": {$gte: 1000000, $lte: 2000000}}
我刚刚想知道这两个字段是否是,最终与服务器将处理的相同查询/问题。还是服务器会以不同的方式处理这两个查询?
我希望最终查询应该相同,但也许只是一个巧合(安慰剂),但我敢肯定,查询#1在我的数据库服务器上运行速度较慢。请原谅我的疯狂杂志,但是,我想知道第一个是否可能不会以相同的方式使用该索引,而是尝试单独处理两个过滤器,然后找到两个结果集的“联合”?
如果后者是真实的,并且确实具有不同的性能,那将是最有效的使用?
I just had a question about the MongoDB querying language. I have a datastore containing a lot of geo-spatial and time series data and I'm attempting to query for records within a time range.
If I'm attempting to search for records who have a field between two values I'm obviously using the $gte and $lte operators.
Consider the two below queries:
Query #1 - Specifying the field twice
{"RecivedTime": {$gte: 1000000}, "ReceivedTime": {$lte: 2000000}}
Query #2 - Two operators on the same field
{"ReceivedTime": {$gte: 1000000, $lte: 2000000}}
I just wondered if these two were, ultimately the same query/question that the server will process. Or if the server will process these two queries differently?
I'd expect that ultimately the queries should be identical, but perhaps it's just a coincidence (placebo) but I'm sure Query #1 runs slower on my database server. Excuse my mad ramblings but, I wondered if it was possible that the first might not use the index in the same way, and instead try to process the two filters individually and then find the "union" of the two result sets?
If the latter is true and they do perform differently, which would be the most efficient to use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论