联接的字段是否将在MongoDB聚合查找查询中使用索引

时间:2019-10-16 02:34:31

标签: mongodb indexing aggregation-framework

示例:

 Widget build(BuildContext context) {
    return new SizedBox(
      width: expandedSize,
      height: expandedSize,
      child: new AnimatedBuilder(
        animation: _animationController,
        builder: (BuildContext context, Widget child) {
          return new Stack(
            alignment: Alignment.center,
            children: <Widget>[

              _buildExpandedBackground(),
              _buildOption(Icons.perm_phone_msg, 0.0),
              Navigator.push(
                context,
                MaterialPageRoute(builder: (context)=>Lover_Page())),
              _buildOption(Icons.calendar_today, -math.pi / 3),
              _buildOption(Icons.assignment_ind, -2 * math.pi / 3),
              _buildOption(Icons.video_call, math.pi),
              _buildOption(Icons.person_add, math.pi / 3),
              _buildOption(Icons.add_a_photo, 2 * math.pi / 3),
              _buildFabCore(),
            ],
          );
        },
      ),
    );
  }

这是Mongodb中的一项联合操作。

如果 foreignField 具有索引,它将使用索引吗?

还有 localField 字段索引。

修改: 用agg添加说明

db.orders.aggregate([
    {
      $lookup:
        {
          from: "inventory",
          localField: "item",
          foreignField: "sku",
          as: "inventory_docs"
        }
   }
])

它没有显示> db.a.explain().aggregate([{ $lookup:{from: "b",localField: "b",foreignField: "b",as: "bs" }}]) { "stages" : [ { "$cursor" : { "query" : { }, "queryPlanner" : { "plannerVersion" : 1, "namespace" : "test.a", "indexFilterSet" : false, "parsedQuery" : { }, "winningPlan" : { "stage" : "COLLSCAN", "direction" : "forward" }, "rejectedPlans" : [ ] } } }, { "$lookup" : { "from" : "b", "as" : "bs", "localField" : "b", "foreignField" : "b" } } ], "ok" : 1, "operationTime" : Timestamp(1571198359, 2), "$clusterTime" : { "clusterTime" : Timestamp(1571198359, 2), "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) } } } 的详细信息。

0 个答案:

没有答案