Search⌘ K

Indexing

Explore indexing in MongoDB to improve query performance by creating meaningful indexes. Learn to manage indexes on collections and embedded documents, including creating, retrieving, and deleting indexes. Understand how indexing affects both read and write operations within MongoDB.

We'll cover the following...

Indexing is a fundamental database concept that improves read performance but also adds additional delay on write operations. So, it’s important that we create only meaningful indexes. An important point to keep in mind is that MongoDB supports indexing on embedded documents as well.

Note: The _id field, which is the primary field, is indexed by default.

Create index

Below is the syntax of the createIndex command.

 ...