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