I am a newbie to MongoDB. I know how Indexes works and what it's importance in MySQL. Are MongoDB indexes are the same as MySQL ?

3 Answers 3


The quick answer is yes. Indexes in MongoDB mostly follow the same logic for usage and creation as you would do in MySQL.

Nevertheless, as the two databases are different (MongoDB is document based, not relational, etc) there are some aspects you might want to consider (for instance, there are no joins - your data model/organization needs to reflect this differences to ensure a good performance).

You might want to check the Indexing Strategies docs page that covers the best ways to take advantage of MongoDB indexes.

Also, besides the "traditional" option, MongoDB has much more index types that can help you achieve different things.


Secondary indexes (non-primary keys) in MongoDB and MySQL are very similar. Secondary indexes declare fields or columns to be sorted separate from the rest of the data, and use row identifiers to reference the rest of the row for a query.


Echoing the earlier comments here, I would agree that indexes in MongoDB are similar in general terms to MySQL. Proper indexing is probably the single easiest factor you can adjust to improve your query performance. Similar to most MySQL storage engines, MongoDB also uses B-tree based indexes. There are some other differences in terms of index types or options supported. For example, I believe MongoDB has more geospatial options than a vanilla MySQL install.

The MongoDB query optimizer, however, is significantly different. The MongoDB query optimizer does periodic empirical analysis of candidate plans for queries, and chooses the plan that will return results most quickly.

For more information, see:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.