3

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!

3

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() with indexDetails option set to true.

Easy copy paste:

.stats({"indexDetails":true})

A document that reports data from the WiredTiger storage engine for each index in the collection. Other storage engines will return an empty document.

The fields in this document are the names of the indexes, while the values themselves are documents that contain statistics for the index provided by the storage engine. These statistics are for internal diagnostic use.

  • 1
    Exactly what I was looking for. Should've RTFM, thanks! – JonLuca Aug 1 '17 at 1:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.