From the course: Data Modeling in MongoDB
Unlock the full course today
Join today to access over 25,200 courses taught by industry experts.
Optimization: Antipatterns - MongoDB Tutorial
From the course: Data Modeling in MongoDB
Optimization: Antipatterns
- [Instructor] In this session, we'll take a high level look at some red flags, or anti-patterns that you should avoid when modeling your collections and creating your database schemas. The first anti-pattern we'll look at is one that we've been talking about throughout this course and that's unbounded arrays. Now there are three major implications here. First, the document size limit is going to be easily reached when your arrays grow without bound, even with small bits of data in the arrays. Querying into an unbounded array is incredibly expensive on the server side, and on the application side, processing a large array for display or other purposes. That's an O-event operation every time. And all of it is very unnecessary when you consider just how much of the data in those arrays actually gets used in the 95% case of your application. Let's consider the case of showing a user's posts. We know that we need to show a���