mongodb - 索引未使用嵌套字段层次结构选取,但在展平模式下选取
问题描述
所以我挣扎了 2 周,为什么当我“解释”我的查询时我的索引没有被选中。
我有这个查询:
{ “$and”: [
{ "extraProperties.class": "Residential" }, { "extraProperties.type": "Sale" }, { "extraProperties.propertyType": "Condo Apartment" }, { "extraProperties.propertyTypeStyle": "Apartment" } ] }
上面的查询不会选择这个索引:
{ “extraProperties.class”:1 , “extraProperties.type” : 1, “extraProperties.propertyType”:1,“extraProperties.propertyTypeStyle”:1}
这些天我一直在测试一切,最后我决定扁平化层次结构,现在我的查询看起来像这样:
{ “$and”: [
{ “class”: “Residential” }, { “type”: “Sale” }, { “propertyType”: “Condo Apartment” }, { “propertyTypeStyle”: “Apartment” }
] }
现在上面的查询将选择这个索引:
{ “class”:1 , “type” : 1, “propertyType”:1,“propertyTypeStyle”:1}
有人可以解释那里到底发生了什么吗?!?!
解释结果:
https://drive.google.com/file/d/1bs_mqO-1FEBHQ_FsBWgP2TQ2jeiQz4q_/view?usp=sharing
解决方案
推荐阅读
- oracle - SP2-0640:未连接
- cordova - 如何检测iTunes商店登录取消(应用购买中的cordova)?
- node.js - 加密敏感信息
- abap - UI5 Odata 批量更新 - 将返回消息连接到单个操作
- javascript - 将 HTML 标记内容传递给 PHP 变量
- python - 使用动态形状广播 tf.matmul
- c# - CLR 类型到 EDM 类型的映射不明确,因为多个 CLR 类型匹配 EDM 类型
- javascript - 使用 async/await 继续执行
- javascript - 如何在不重新加载的情况下动态更新谷歌地图的标记
- mysql - MySQL - 月份选择命令