So you’ve worked with relational databases and can write SQL queries like a pro. Then your team decides to dabble in NoSQL and throws MongoDB into the database architecture. Where do you, the seasoned SQL DBA, even begin?
The reality is, most DBAs already have to deal with both SQL and NoSQL databases, and the trend shows it will be a mix of both for a while. But it’s no reason to be intimidated: With these six tips, you’ll be properly equipped for your new MongoDB tasks in no time.
Speak the (MongoDB query) language
With MongoDB in your database mix, you’ll be expected to query your databases and run reports. And for that, you’ll need to know the right commands.
A good place to start is MongoDB’s documentation, but there are also MongoDB tools that will accelerate your query writing skills.
It even lets you use SQL to query MongoDB, the very first MongoDB GUI to do so.
Monitor and measure
Part of closely monitoring your database is that you can diagnose problems earlier. It’s better to prevent a death on the server than conduct the post-mortem. As Amazon once eloquently put it:
So what exactly do you need to measure?
MongoDB’s claim to mainstream NoSQL fame is its ability to scale, thanks to sharding capabilities designed to spread storage across multiple servers. As a MongoDB DBA, shard metrics should be part of your list, like keeping an eye out on how the load being balanced across shards.
As with any other database, you also need to consider host metrics. Are you fully utilizing your databases? How’s your network behaving? While you can anticipate workload changes, it is equally important to monitor any capacity changes so that your team can make adjustments in time.
Then there’s the daily grind. To monitor standard operations, metrics like operation counts and network requests will help you capture any changes in your team’s MongoDB usage.
Manage your MongoDB indexes
Think of indexes in MongoDB as what sitemaps are to Google. They help “guide” your MongoDB to scan fewer documents to satisfy a query, sparing the need to go through all documents which worsens performance.
The takeaway here is, indexes speed up queries significantly.
MongoDB supports several index types, which you can easily add and modify using MongoDB tools.
Schema design is still important
Another MongoDB claim to fame is its schema-less design, which attracted many developers and startups whose evolving ideas would have been limited by a set structure.
While it’s advantageous to work with a database with room for flexibility and agility, it’s still critical for a DBA to anticipate the needs and understand the requirements of a given project.
Know which data would benefit from the structure of a relational database or the flexibility of a non-relational one, while keeping in mind that hybrid approaches might be the way to go. MongoDB has been known to support wildly differing use cases, with companies large and small continuing to choose it for increasingly complex projects.
Once you’ve defined your schema design, MongoDB tools like Studio 3T can help you keep track of your data’s schema to make sure you and your team always adhere to it.
Secure your database
You’ve likely heard about the recent ransomware attacks on MongoDB, and it goes without saying that you need to secure your MongoDB database. What’s important to understand here is that the culprit is not the database, but the failure to activate MongoDB’s built-in authentication mechanisms.
Have a look at MongoDB’s security checklist and these steps, which were published following the wave of malware attacks, to make sure you’re covered.
Take advantage of MongoDB resources
In addition to their excellent documentation, MongoDB also runs MongoDB University, where you can enroll in introductory to advanced courses for free. Courses run on a set schedule, so make sure you register in time.
MongoDB also administers the MongoDB Certified DBA Associate Level Exam, which is something to keep in mind as you hone your MongoDB skills. At 150 USD, you can take the exam, earn a certification, and pimp up your LinkedIn profile.
And if you’re looking to learn MongoDB as part of a wider tech stack, we recommend that you check out MEAN and MERN.