3

Suppose I have a three documents where "B" field is present. All the three have 3 different datatypes. How the Index BTREE is stored? And making "B" as an index key is efficient?

Example.

{_id:"1",a:1,b:"abc" }        //B is string here 
{_id:"1",a:1,b:[1,2,3] }      //B is array of numbers
{_id:"1",a:1,b:{x:1,y:"a"} }  //B is another nested document
1
  • Perfect. Thank you so much. So SORT mechanism is there even in BTREE node placements Commented Sep 1, 2014 at 16:44

1 Answer 1

5

It doesn't work any different than if they are all the same type. It's not any more or less efficient than if they are all the same type. Just be aware of how sorting will work- different types will be compared by the BSON type ordering.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.