Mysql – How MongoDB indexes differs from MySQL indexes

indexmongodbMySQL

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 ?

Best Answer

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.