Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Does mongodb discriminate between indices constructed of small, statically sized elements (lets say numeric types) and those with large variant types (such as strings) ?

From the BSON spec I can see that BSON does show the capacity of special treatment of integral types. I would expect the indexing code to create more performant indices if the index contains only int64's.

Perhaps it has some form of discriminated union ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.8k views
Welcome To Ask or Share your Answers For Others

1 Answer

The B-Tree contents are basically just the BSON serialized representation of the indexed fields and a pointer to the disk location of that object.

Here is a link to the code where it mentions this. In fact, here is the woCompare function they use while looping through the index.

Looks to me like a simple binary comparison, so smaller data will compare faster than larger data.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...