From the course: Databases for Node.js Developers
Unlock this course with a free trial
Join today to access over 24,400 courses taught by industry experts.
Optimizing queries with indexes - Node.js Tutorial
From the course: Databases for Node.js Developers
Optimizing queries with indexes
- [Instructor] Indexes are a key concept in any type of database, whether relational or non-relational. They are like the index of a book. If you're looking for something specific, the index helps you find it quickly instead of flipping through every single page. In MongoDB, indexes make your queries faster, especially when working with large data sets. They also let us enforce rules like uniqueness, and optimized filtering for sorting operations. Right now and we see this among the big compass, we already have indexes in place. So when I look now into the items collection, and click on the indexes tab, you see that we have an index, which is unique on this ID field we talked about. This is the document ID that is given to us from MongoDB directly, and we also have a unique index SQ. And if you remember that we defined this in the model. So this unique index ensures that no two items can have the same SQ, and it also makes queries way faster because when I now look for an SQ, and it's…
Contents
-
-
-
-
-
(Locked)
Managing product data with MongoDB33s
-
Setting up MongoDB with Docker2m 30s
-
(Locked)
Exploring MongoDB with Compass1m 19s
-
(Locked)
Introducing Mongoose2m 59s
-
(Locked)
Setting up Mongoose and connecting it to MongoDB10m 14s
-
(Locked)
Building a model for our products5m 25s
-
(Locked)
Integrating the model into our application3m 55s
-
(Locked)
Populating MongoDB with sample data2m 6s
-
(Locked)
Querying items with Mongoose9m 19s
-
(Locked)
Filtering items by tag4m 27s
-
(Locked)
Item administration: Listing and loading6m 32s
-
(Locked)
Item administration: Create, update, and delete15m 14s
-
(Locked)
Optimizing queries with indexes5m 33s
-
(Locked)
Performing text search in MongoDB5m 34s
-
(Locked)
-
-
-
-