mongodb aggregation 彙總

來源:互聯網
上載者:User
Aggregation Pipeline Behavior
In MongoDB, the aggregate command operates on a single collection, logically passing the entire collection into
the aggregation pipeline. To optimize the operation, wherever possible, use the following strategies to avoid scanning

the entire collection.

彙總管道表現

在Mongodb,彙總命令在單個collection上進行操作,邏輯上是吧整個collection傳進彙總管道。為了最佳化操作,儘可能的在能用到的地方使用以下的策略去避免掃描整個collection。


Pipeline Operators and Indexes
The $match and $sort pipeline operators can take advantage of an index when they occur at the beginning of the
pipeline.
New in version 2.4: 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.
Even when the pipeline uses an index, aggregation still requires access to the actual documents; i.e. indexes cannot
fully cover an aggregation pipeline.

Changed in version 2.6: In previous versions, for very select use cases, an index could cover a pipeline.

管道操作以及索引

對於 $match and $sortd管道操作,當他們發生在管道的開始可以充分利用索引的優勢。

在新的版本2.4中: $geoNear管道操作利用了地理空間索引geospatial,當使用geospatial,

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.