Key Concepts

Review core concepts you need to learn to master this subject

MongoDB Indexes

In MongoDB, an index is a data structure that captures a subset of a collection’s data in an easy to traverse form. Indexes store the value of a specific field or fields, and attach a reference to the original document to each index entry. Indexed values are organized in either ascending or descending order.

Introduction to Indexing
Lesson 1 of 1
  1. 1
    In MongoDB, indexes play an important role in making sure our database performs optimally. Recall, an [index](…
  2. 2
    Since using indexing in MongoDB is tied closely to database performance, it would be ideal to have a way to see how our indexes impact our queries. The [.explain()](…
  3. 3
    In addition to single field indexes, MongoDB gives us the ability to create compound indexes. [Compound indexes](…
  4. 4
    How do MongoDB indexes handle fields whose values are arrays? Conveniently, MongoDB automatically creates what’s known as a [multikey index](…
  5. 5
    Is it possible to create a compound multikey index in MongoDB? The answer is yes, with a [very important caveat](…
  6. 6
    Each time we make changes to a collection, any indexes associated with that collection must also be updated. In this way, unnecessary indexes can slow down the performance of certain CRUD operation…
  7. 7
    We’ve just learned how to create and manage indexes in MongoDB. Let’s recap some key takeaways from this lesson: * An index is a data structure that captures a subset of a collection’s data in an …

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo