我在这里试图深入了解 B 树是如何创建的。
假设我使用一个数字作为索引变量。如何创建深度 =1 的树还是会像这样 - http://knol.google.com/k/-/-/pz98o7ulrif9/zvd1ua/difftree01.png
如果是树的深度是多少,子节点的最大数量是多少。
对于复合键(比如 2 个索引变量),是否会有两棵树。或者它是一棵单棵树,第一级作为第一个键,第二级作为第二个键?
假设我将时间戳作为索引键。我可以把它做成一棵树,第一层是年,第二层是月,第三层是日。 mongoDB能自动解析出这些信息吗?
I am trying here to get a insight on how the B tree is created.
Lets say i am using a number as a index variable. How will the tree be created with depth =1 or Would it be like this - http://knol.google.com/k/-/-/pz98o7ulrif9/zvd1ua/difftree01.png
If so what would be the depth of the tree and what would be the maximum number of children.
For compound keys (say 2 index variables), will there be two trees. Or would it be a single tree with first level as first key and second level as second key ?
Say i take timestamp as the index key. Can i make it as a tree with first layer as years , second as month , and third as day . Can mongoDB automatically parse this information out?
发布评论
评论(1)
您的图片显示“二叉树”而不是“b树”,它们是不同的。
“B 树”的工作原理是创建给定大小的存储桶(相信 MongoDB 使用 4k)并对这些存储桶中的项目进行排序。
请查看维基百科上有关 B 树的条目,它应该为您提供明确的答案。
只有一棵树。然而,存储在树中的密钥基本上是两个项目“混合”在一起的 BSON 表示。
不,您无法控制索引结构。
No MongoDB 不支持对索引中的日期进行任何特殊解析。
如果对时间戳进行比较操作,则需要发送另一个时间戳。
Your picture shows a "binary tree" not a "b-tree", these are different.
"B-tree" works by creating buckets of a given size (believe MongoDB uses 4k) and ordering items within those buckets.
Please take a look at the Wikipedia entry on B-trees, it should provide a definitive answer for you.
Only one tree. However the key stored in the tree is basically the BSON representation of both items "mushed" together.
No, you have no control over the indexing structure.
No MongoDB does not support any special parsing on dates in indexes.
If you do a comparison operation for timestamps, you will need to send in another timestamp.