Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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 ?

share|improve this question

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.

share|improve this answer

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.

share|improve this answer

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:

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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