O'Reilly logo

MongoDB for Java Developers by Francesco Marchioni

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using indexes in your applications

The concept of an index in a database is pretty equivalent to the index contained in a book. So, instead of searching for a section across all the pages of the book onwards, you search for the relevant section in the index and then open the book on that page.

This concept has been adopted by all relational databases and it works quite the same on MongoDB, that is, by creating a special data structure that is able to store a small part of the collection's dataset in such a way that is easy to traverse from.

Without using indexes, MongoDB must perform an expensive collection scan, which means to scan every document in a collection, in order to find those documents that match the query string. Indexes can improve ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required