Indexes management

Hi community,

I’m trying to manage indexes for my collections, and running this command db.orders.aggregate( [ { $indexStats: { } } ] ) to get the index info, from the result of the index stats, it has an accesses prop, and within the accesses prop, it has a count and since prop available for me to check out how many times this index has been used since a date.

is there any chance to change the retention date for this since prop, so it’s longer? from my observation, it only captures the latest 7-10 days, how can I capture index usage for the latest 30 days or 60 days for example.

Any insights?


I believe that the indexStats command does not accept any parameters and there’s no way to configure the retention period for the data it collects. It’s also reset on the restart of a mongod process or similar things like that.

Though if what you want to do a in-depth performance investigation, MongoDB FTDC might hold more information for you to use -

Even MongoDB Atlas’ Performance Advisor seems to be only able to go back as far as 7 days.