...
So far we’ve only seen the limit
and project
stages, however, there are many other stages available in Mongo. The common stages are listed in the table below.
Name | Description |
---|---|
Reshapes the records from the previous stage of the pipeline for the next stage. | |
Filters the records from the previous stage of the pipeline for the next stage. | |
Limits the number of records from the previous stage of the pipeline for the next stage. | |
Skips a number of records from the previous stage of the pipeline for the next stage. | |
Groups records by a specified identifier from the previous stage of the pipeline for the next stage. | |
Sorts the records from the previous stage of the pipeline for the next stage. |
...
You may find that changing the match stage can vary the time it takes a query to run, especially when you have a large number of statements. You can take advantage of database indexes to improve performance, more information is available about using indexes in the match stage via Mongo’s documentation. If utilising indexes doesn’t have the required performance improvement, you can instead utilise our Connection HTTP Interface or BI tools.
LIMIT STAGE
For example, to limit the interface to returning 1 statement, you can use the following request. You can find out more about the limit stage via the Mongo documentation.
...
You may find that changing the sort stage can vary the time it takes a query to run, especially when you have a large number of statements. You can take advantage of database indexes to improve performance, more information is available about using indexes in the sort stage via Mongo’s documentation. If utilising indexes doesn’t have the required performance improvement, you can instead utilise our Connection HTTP Interface or BI tools.