MongoDB for Developers with Python Transcripts
Chapter: High-performance MongoDB
Lecture: A popular dealership
Login or
purchase this course
to watch this video and the rest of the course contents.
0:01
Let's return to our dealership. This was the example we started back when we began the MongoEngine section,
0:06
and it turns out the dealership is super popular now. Before we just had a couple of cars, now we have a quarter million cars
0:12
in our database, we have a 100 thousand owners, I don't believe we talked about owners before in terms of what that looks like in our code,
0:20
but I've added this concept of owners so we can ask interesting like cross-document related type questions,
0:26
and we'll look at the details of them, when we get to the code, in just a moment. Each one of these owners, these 100 thousand owners,
0:32
owns an average of 2.5 cars, this is kind of like collectors, right, not a standard person that drives to work or whatever, these are Ferraries,
0:40
and each car has on average about 5 service records and that could be like a new engine, change the tires, change the spark plug, whatever;
0:49
in particular, there's about 1.25 million service histories, so when we ask questions about like those nested documents
0:55
that have to do with service histories like customer ratings and price, you can see that that is really quite impressive I think,
1:02
we got the quarter million cars and within those quarter million documents interspersed are 1.25 million service histories.
1:08
So our job is to make a lot of the typical things that we might ask this database,
1:12
the queries will run to do so in a couple of milliseconds, not in seconds, so that's going to be what the basic goal of this whole section is.
1:24
Now, the other things you might want to know is we've got about 180 megs of data and on average each document of the various document kinds,
1:31
all average together is about 500 bytes per document. So let's return to or example slightly transformed
1:38
and see how it's performing now and let's make it fast.