YulePale
YulePale

Reputation: 7706

How to view MongoDB indexes data structure?

In the MongoDB docs it is stated that

Indexes are special data structures [1] that store a small portion of the collection’s data set in an easy to traverse form.

How can I see these data structures? Is it possible?

I was going through this question and I saw that in this answer they gave an example of a schema for an index. Is there such a thing in MongoDB that is what I am trying to see. I am trying to understand indexes in MongoDB better.

Upvotes: 1

Views: 510

Answers (1)

Tom Slabbaert
Tom Slabbaert

Reputation: 22296

When you create an index in Mongo (using createIndex) you specify which fields the index will use, or what you call the index "schema".

As mentioned in the docs these indexes are built as b-trees (don't read too much into this as indexes are a "black box" for us users), viewing the exact tree structure is not possible, but you can use indexStats to get some more information on an index you created.

Upvotes: 2

Related Questions