07 / 18

How to drop an index?

You may need to drop an index if you see a negative performance impact, want to replace it with a new index, or no longer need the index.

  1. 1

    You can drop any index except the default index on the _id field. To drop the _id index, you must drop the entire collection.

  2. 2

    To drop an index, you need its name. To get all index names for a collection, run the getIndexes() method

After you identify which indexes to drop, use one of the following drop methods for the specified collection:
  1. 1

    db.<collection>.dropIndex('<indexName>')

  2. 2

    db.<collection>.dropIndexes( [ '<index1>', '<index2>', '<index3>' ] )