I have a mongodb database with about 2 billion records, shared between 20 or so collections. Each of these collections has an index on it, based on a single key (other than _id).
I have an index file (named index-1-5374774422504609475.wt) that I'd like to match to a collection. Is there a quick way to match directly which index file corresponds to a collection?
I do mean the actual physical index file in the mongo db directory.
Thanks in advance!
Best Answer
Ref: https://docs.mongodb.com/manual/reference/method/db.collection.stats/
https://docs.mongodb.com/manual/reference/command/collStats/#collStats.indexDetails
As you are using WiredTiger storage engine you can use
db.collection.stats()
withindexDetails
option set totrue
.Easy copy paste:
.stats({"indexDetails":true})