How to use indexes properly in MongoDB

An issue we often ignore in MongoDB is the indexes. We may take for granted that MongoDB works like Elasticsearch and all fields are indexed by default. Actually, this is not true! In MongoDB, only the _id field is automatically indexed and we need to build indexes for the fields that are queried frequently to support the queries efficiently. Otherwise, the queries can be very inefficient and will degrade the performance of the MongoDB server.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Lynn Kwong

Lynn Kwong

440 Followers

I’m a Software Developer (https://www.superdataminer.com) keen on sharing thoughts, tutorials, and solutions for the best practice of software development.