Shing Lyu

Check MongoDB index usage statistics

By Shing Lyu    

Disclaimer: This content reflects my personal opinions, not those of any organizations I am or have been affiliated with. Code samples are provided for illustration purposes only, use with caution and test thoroughly before deployment.

Run this command to get the usage of each index:

db.<collection>.aggregate( [ { $indexStats: { } } ] )

This is useful for figuring out which index is underutilized. You can find an example output in the documentation.

Want to learn Rust? Check out my book: