MongoDB for Developers with Python Transcripts
Chapter: High-performance MongoDB
Lecture: Introducing performance-tuning in MongoDB
Login or
purchase this course
to watch this video and the rest of the course contents.
0:01
Now that you know how to work MongoDB, you know how to work its shell,
0:04
what the query syntax is, you've seen PyMongo as well as MongoEngine,
0:07
it's time to turn our attention to tuning MongoDB
0:11
to be the best database it can possibly be.
0:14
We're going to focus on how to make our regular MongoDB server
0:18
a high performance MongoDB database
0:21
and you'll see there's no magic here, a lot of the things that you can do
0:24
are relatively straightforward, and there's a systematic way to go about it.
0:29
I want to start this section by maybe putting a little perspective on it.
0:34
I want to start this section, this chapter, by putting a little perspective out there.
0:41
When people come to NoSql and they start looking for alternative databases
0:44
often the allure of these databases is their performance
0:49
you hear about things like sharding, horizontally scaling them,
0:52
some incredible performance numbers, things like that.
0:55
That may be what you really need, that may be the most important thing
0:58
and certainly if you don't have performance out of your database it's a big problem.
1:03
We're going to certainly figure out how to make our databases faster
1:07
and the variety of techniques that we have available to us in MongoDB.
1:11
That said, your biggest problem probably isn't performance,
1:14
you may have a big data problem, you may have terabytes or petabytes of data
1:19
but most applications don't.
1:22
You may have a performance problem, it may be that you have so much data
1:26
or you are asking such complex queries that it really does take
1:30
very precise tuning and scaling to make it work.
1:33
So we're going to focus on some of these types of things.
1:36
That said, we all have a complexity problem with our application,
1:40
it's always a pain to maintain these databases
1:43
especially when we're working with relational databases,
1:46
you hear about things like migrations and updating your schema
1:49
adding, removing, transforming columns, all of this stuff is really complex
1:53
and it even makes deployment really, really challenging,
1:56
you want to release a new version of something based on SQLAlchemy
1:59
but you need to change the database scheme before it will even run—
2:02
okay, that sounds like it could be a little bit of a problem.
2:05
What you'll see with MongoDB and these document databases is
2:10
one of their biggest benefits is the simplicity that they bring.
2:14
The document structure means there's fewer tables,
2:18
there is much fewer connections between these tables,
2:21
so when you think about the trade-offs and performance and things like that
2:24
keep in mind that probably the biggest benefit
2:27
that you are going to get from MongoDB is you are going to have
2:30
simpler versioning, evolution, maintainability, development story.
2:33
I just want to put that out there, because I know sometimes
2:36
people will say well, I got MongoDB to perform at this speed
2:40
and I cut this other database, and if I tweak it like this and adapt it like that
2:44
maybe I could get it to go a little faster, so maybe we should use that instead.
2:47
And maybe, I don't know, it depends on the situation,
2:50
and this is very abstract, so it's hard to say, but keep in mind
2:53
that one of the biggest things these document databases
2:55
bring to you to the table here, is this simplicity.
2:59
It just so happens we can also make them really, really fast.
3:03
So simple and fast, sounds like a great combination,
3:05
so let's get into this section where we are going to make MongoDB much faster.