Index Responsibly

Indexes make the execution of queries efficient in MongoDB because without indexes, MongoDB must scan every document in a collection. However, having indexes adds overhead to update indexes for write operations. Keyhole prints the details of all indexes and their usages using the -index option. This is useful to identify redundant and/or unused indexes of collections. Indexes and Usages Below is an example of showing indexes and their usages of collection mdb.numbers from a 2-shard sharded cluster. Keyhole highlights redundant indexes in red with a leading ‘ x ’ and unused indexes since the mongo server started in blue with a leading ‘ ? ’. A shard key is with a leading ‘ * ’ character. Usually, redundant indexes are those that can be covered by another compound index. On the other hand, before dropping any unused indexes, check with the development teams on the purpose of creating those in the first place. See example outputs below: $ keyhole --index "mongodb+srv://user: