Tuesday, August 15, 2017

MongoDB: Evaluate Query Performance Using Indexes

DZone Database Zone
MongoDB: Evaluate Query Performance Using Indexes

This blog shows commands that you can use to manage MongoDB indexes on a particular collection, as well as tips on how to evaluate query performance with or without indexes. 

Why Create Indexes?

Indexes can significantly improve read query performance for MongoDB collections. In the absence of indexes, when searching for documents based on filter criteria, MongoDB performs a collection scan in which it scans every document and returns the documents matching the filter criteria. This is not a very efficient way of searching the document. For example, if one or more fields are frequently used for filtering out the document, it is recommended to create indexes on those fields. MongoDB thus limits the number of documents that are scanned when indexes are present. When there are fewer documents being scanned, there is faster query execution time.

No comments:

Fun With SQL: Functions in Postgres

DZone Database Zone Fun With SQL: Functions in Postgres In our previous  Fun with SQL  post on the  Citus Data  blog, we covered w...