Schema Suggestions in MongoDB Atlas: Years of Best Practices, Instantly Available To You
Not everyone brings to the table years of data modeling experience when working with document databases. We’ve seen that when relational modeling patterns are implemented in MongoDB, applications don’t run as efficiently and cost-effectively as possible.
The good news is that we don’t care about your ex. We believe that your history with other types of databases shouldn’t impede your ability to build high-performance applications with us. That’s why we’re debuting the newest functionality of MongoDB Atlas: automated schema suggestions.
Schema suggestions empower you to make choices that optimize for MongoDB’s document data model, whether you’re just starting out or already have an app in production. By providing actionable and personalized recommendations, we’re further investing in making MongoDB Atlas even easier for developers to use.
How do schema suggestions work?
Atlas can now intelligently scan your schema for common anti-patterns and give real-time recommendations that align to MongoDB’s best practices.
Schema suggestions are grouped by common anti-patterns known to affect performance in MongoDB, as detected from samples of your document and collection metadata, not the underlying data itself. We worked closely with MongoDB experts and our support team to identify common anti-patterns by analyzing common data modeling behavior used by some customers moving from relational databases to MongoDB.
Using relational data patterns in MongoDB can be counterproductive because MongoDB, by design, is fundamentally different from relational databases. In order for your database to function at its best, your data needs to be structured differently. The good news is that these structures often closely match the objects you use in your code. We’ve noted the most common pitfalls in working with documents by creating these schema suggestions. Each suggestion offers supporting evidence and context for why it surfaced so developers can quickly evaluate its potential impact and importance.
Atlas currently offers the following schema suggestions:
- Avoid Unbounded Arrays
- Reduce Number of Collections
- Remove Unnecessary Indexes
- Improve Case-Insensitive Regex Queries
- Reduce Size of Large Documents
Where can I find schema suggestions within Atlas?
Schema suggestions can be found within both the Performance Advisor and Data Explorer in the Atlas UI. For those who aren’t familiar with either of these tools yet, the Performance Advisor is a unique optimization tool that surfaces index recommendations based on slow query logs and offers click-to-create index functionality. Data Explorer is another popular tool within Atlas that allows you to view and interact with your data by managing your cluster’s databases, collections, documents, and more.
Check out this tutorial to visualize where you can find schema suggestions, hear more about how they work, and how they can help you.
Schema suggestions in the Performance Advisor give actionable recommendations on the collections with the slowest operations and the most activity, meaning we surface the most important schema suggestions you should focus on. This makes schema suggestions within the Performance Advisor most useful for apps in production with multiple collections. The Performance Advisor is currently available on every dedicated (M10+ or higher) cluster. Here’s what a schema suggestion looks like in the Performance Advisor.
Each schema suggestion is composed of the issue/anti-pattern detected, where the issue is found with a link to affected collections in Data Explorer, and the importance of addressing the issue. The title of each schema suggestion is the action we recommend you take and by clicking the green button labeled “Learn How to Fix This Issue”, you’ll be directed to documentation with instructions and examples on how to take action. If you still need assistance, the “Chat with an Expert” button on the bottom right takes you to our support page.
Within Data Explorer (the Collections view), you can view schema suggestions for a single collection. This provides a more fine-grained view, useful for investigating a specific collection as you build new features in your application. Within the Data Explorer, you have the opportunity to validate the track you’re on from any active development stage. Note that when initially developing your application, it may take a while for schema suggestions to surface as they are based on detecting certain thresholds of anti-patterns within your documents.
Every cluster, including our free-forever tier, can receive schema suggestions in Data Explorer. If you want to see what that looks like, here’s a schema suggestion in Data Explorer.
Where can I learn more about data modeling?
If you don't have an Atlas account, you can always sign up today. If you do, you can visit the Performance Advisor to see if you have any schema suggestions. We’ll be adding more anti-patterns as we continue to iterate on this feature, but in the meantime, we welcome any suggestions you may have at feedback.mongodb.com.
To learn more about data modeling best practices, visit our documentation or check out our developer blog series on schema design patterns and anti-patterns.
Try MongoDB in the Cloud
Create a free account and launch a cluster in minutes!