【问题标题】:Why I cannot see the name of the index mongodb uses?为什么我看不到 mongodb 使用的索引的名称?
【发布时间】:2012-09-11 12:53:03
【问题描述】:
db.tablebusiness.find({ "LongitudeLatitude" : { "$nearSphere" : [106.772835, -6.186753], "$maxDistance" : 0.053980478460939611 }, "Prominent" : { "$gte" : 15 }, "indexContents" : { "$all" : [/^soto/, /^nasi/] } }).limit(200).explain();




{
        "cursor" : "GeoSearchCursor",
        "nscanned" : 48,
        **"nscannedObjects" : 48,**
        "n" : 48,
        "millis" : 8563,
        "nYields" : 0,
        "nChunkSkips" : 0,
        "isMultiKey" : false,
        "indexOnly" : false,
        "indexBounds" : {
        }
}
>

那么索引的名称是什么?我看到一些问题确实出现了索引名称。以MongoDB: why doesn't sorting by multiple keys use an index? 为例

我还听说过 explain(true) 在这里根本没有记录的地方:

http://www.mongodb.org/display/DOCS/Explain

【问题讨论】:

  • 请注意,mongodb.org/display/DOCS/Geospatial+Indexing 表示每个集合可能只有 1 个地理空间索引。这意味着“GeoSearchCursor”必须使用那个索引。
  • 等一下。如果我们有时想搜索按突出排序的点,而后者想根据标题搜索点,那该怎么办。我们需要 2 个地理空间索引,每个索引属于两个不同的组合。

标签: mongodb indexing


【解决方案1】:

我不确定这是故意的还是有缺陷的,但是当使用地理空间索引时,所用索引的名称不会显示在解释计划中。

只有在使用 BtreeCursor 时才会显示索引名称。

如上面评论中所述,一个集合中只能有一个地理空间索引。在此参数下,您可以假设如果光标是“GeoSearchCursor”,则它正在使用您想要的该集合的索引。

【讨论】:

    【解决方案2】:

    这是一个已知问题。请看https://jira.mongodb.org/browse/SERVER-4213

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-21
      • 2015-08-18
      • 1970-01-01
      • 1970-01-01
      • 2015-10-18
      • 2014-03-18
      • 1970-01-01
      相关资源
      最近更新 更多