How to match a WiredTiger index file to its corresponding collection

Posted on

Question :

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!

Answer :


As you are using WiredTiger storage engine you can use db.collection.stats() with indexDetails option set to true.

Easy copy paste:


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.

Leave a Reply

Your email address will not be published. Required fields are marked *