Hint and sparse indexes

By design, sparse indexes do not include some documents in the index, based on the presence/absence of a field. Queries that may include documents that are not present in the index will not use a sparse index.

Using hint() with a sparse index may result in incorrect counts, since it is forcing MongoDB to use an index that may not include all of the results that we want.

Older versions of 2dsphere, 2d, geoHaystack, and text indexes are sparse, by default. hint() should be used with caution, and after careful consideration of its implications.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset