MongoDB Aggregation Aggregation

Source: Internet
Author: User
Tags mongodb advantage
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.

Aggregation Pipeline Performance

In MongoDB, the aggregation command operates on a single collection, logically, the entire collection is passed into the aggregation pipeline. To optimize the operation, use the following strategies wherever possible to avoid scanning the entire collection.


Pipeline Operators and Indexes
The $match and $sort pipeline operators can take advantage of a 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 a 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.

Pipeline Operations and indexing

For $match and $SORTD pipeline operations, the benefits of indexing can be fully leveraged when they occur at the beginning of the pipeline.

In the new version 2.4: $geoNear pipeline Operation leverages the geospatial index geospatial, when using geospatial,

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.