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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With