MongoDB Documentation, Release 3.0.4 11.8.5 How do you know what index a query used? 11.8.6 How do you determine what fields to index? 11.8.7 How do write operations affect indexes? 11.8.8 Will building a large index affect database performance? 11.8.9 Can I use index keys to constrain query matches? 11.8.10 Using $ne and $nin in a query is slow. Why? 11.8.11 Can I use a multi-key index to support a query for a whole array? Chapter 11. Frequently Asked Questions 778 Not entirely. The index can partially support these queries because it can speed the selection of the first element of the array; however, comparing all subsequent items in the array cannot use the index and must scan the documents individually. The $ne and $nin operators are not selective. See Create Queries that Ensure Selectivity (page 550). If you need to use these, it is often best to make sure that an additional, more selective criterion is part of the query. You can use the min() and max() methods to constrain the results of the cursor returned from find() by using index keys. If you build a large index without the background option, and if doing so causes the database to stop responding, do one of the following: Building an index can be an IO-intensive operation, especially if you have a large collection. This is true on any database system that supports secondary indexes, including MySQL. If you need to build an index on a large collection, consider building the index in the background. See Index Creation (page 507). Any write operation that alters an indexed field requires an update to the index in addition to the document itself. If you update a document that causes the document to grow beyond the allotted record size, then MongoDB must update all indexes that include this document as part of the update operation. Therefore, if your application is write-heavy, creating too many indexes might affect performance. A number of factors determine what fields to index, including selectivity (page 550), fitting indexes into RAM, reusing indexes in multiple queries when possible, and creating indexes that can support all the fields in a given query. For detailed documentation on choosing which fields to index, see Indexing Tutorials (page 517). To inspect how MongoDB processes a query, use the explain() method in the mongo shell, or in your application driver. • Wait for the index to finish building. • Kill the current operation (see db.killOp() ). The partial index will be deleted.