This version will reach end of life on Feb 2018. To upgrade, go to the Learn more about upgrading your version of MongoDB.

Create a Sparse Index

Sparse indexes are like non-sparse indexes, except that they omit references to documents that do not include the indexed field. For fields that are only present in some documents sparse indexes may provide a significant space savings. See Sparse Indexes for more information about sparse indexes and their use.

See also

Index Concepts and Indexing Tutorials for more information.


To create a sparse index on a field, use an operation that resembles the following prototype:

db.collection.createIndex( { a: 1 }, { sparse: true } )


The following operation, creates a sparse index on the users collection that only includes a document in the index if the twitter_name field exists in a document.

db.users.createIndex( { twitter_name: 1 }, { sparse: true } )

The index excludes all documents that do not include the twitter_name field.



Sparse indexes can affect the results returned by the query, particularly with respect to sorts on fields not included in the index. See the sparse index section for more information.