A Better MongoDB Aggregation Experience Via Compass
Rate this announcement
MongoDB Compass has had an aggregation pipeline builder since 2018. Its primary focus has always been enabling developers to quickly prototype and troubleshoot aggregations. Aggregations would then be exported to the developer’s preferred programming language and copy-pasted inside application code.
As of MongoDB World 2022, we are relaunching the aggregation experience within Compass, and we’re happy to announce richer, more powerful functionality for developers.
Compass 1.32.x series includes the following:
In-Use encryption, including providing options for KMS details in the connection form and CRUD support for encrypted collections, and more specifically for Queryable Encryption when creating collections
Saved queries and aggregations in the My Queries tab
Explain plan for aggregations
Run aggregations against the whole collection
Export aggregation results
Below, we will talk a bit more about each of these features and how they are useful to developers.
Our latest release of MongoDB Compass provides options for using KMS details in the connection form, as well as CRUD support for encrypted collections. Specifically, we also include functionality for Queryable Encryption when creating a collection.
Users can already save aggregations in Compass for later use.
However, saved aggregations are bound to a namespace and what we’ve seen often is that our users had trouble finding again the queries and aggregations they’ve saved and reuse them across namespaces. We decided the experience had to be improved: developers often reuse code they’ve written in the past as a starting point for new code. Similarly, they’ve told us that the queries and aggregations they saved are their “best queries”, the ones they want to use as the basis to build new ones.
We took their input seriously and recently we added a new “My Queries” screen to Compass. Now, you can find all your queries and aggregations in one place, you can filter them by namespace and search across all of them.
When building aggregations for collections with more than a few hundreds documents, performance best practices start to become important.
“Explain Plan” is the most reliable way to understand the performance of an aggregation and ensure it’s using the right indexes, so it was not surprising to see a feature request for explaining aggregations quickly rising up to be in the top five requests in our feedback portal.
Now “Explain Plan” is finally available and built into the aggregation-building experience: with just one click you can dig into the performance metrics for your aggregations, monitor the execution time, and double-check that the right indexes are in place.
However, the role of a developer in a modern engineering team is expanding to include tasks related to gathering users and product insights from live data (what we sometimes refer to as real-time analytics) and generating reports for other functions in the team or in the company.
When this happens, users are puzzled about not having the ability to run the aggregations they have created on the full dataset and export results in the same way they can do with a query. This is understandable and it’s reasonable that they assume this to be table-stakes functionality in a database GUI.
Now this is finally possible. Once you are done building your aggregation, you can just click “Run” and wait for the results to appear. You can also export them as JSON or CSV, which is something really useful when you need to share the insights you’ve extracted with other parts of the business.
In summary, the latest version of MongoDB Compass means that users of MongoDB that are exploring the aggregation framework can get started more easily and build their first aggregations in no time without reading a lot of documentation. Experts and established users will be able to get more out of the aggregation framework by creating and reuse aggregations more effectively, including sharing them with teammates, confirming their performance, and running the aggregation via Compass directly.
If you're interested in trying Compass, download for free here.