Mongodb 聚合框架:$group 是否使用索引? [英] Mongodb Aggregation Framework: Does $group use index?

查看:60
本文介绍了Mongodb 聚合框架:$group 是否使用索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用带有 $match$group 阶段的聚合框架.$group 阶段是否使用索引数据?我正在使用最新的可用 mongodb 版本 - 2.5.4

I'm trying to use aggregation framework with $match and $group stages. Does $group stage use index data? I'm using latest available mongodb version - 2.5.4

推荐答案

$group 不使用索引数据.

来自 mongoDB 文档:

From the mongoDB docs:

当 $match 和 $sort 管道运算符出现在管道的开头时,它们可以利用索引.

The $match and $sort pipeline operators can take advantage of an index when they occur at the beginning of the pipeline.

$geoNear 管道运算符利用了地理空间索引.使用 $geoNear 时,$geoNear 管道操作必须显示为聚合管道的第一阶段.

The $geoNear pipeline operator takes advantage of a geospatial index. When using $geoNear, the $geoNear pipeline operation must appear as the first stage in an aggregation pipeline.

这篇关于Mongodb 聚合框架:$group 是否使用索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆