B+-Trees (Part 1).ppt
《B+-Trees (Part 1).ppt》由会员分享,可在线阅读,更多相关《B+-Trees (Part 1).ppt(28页珍藏版)》请在麦多课文档分享上搜索。
1、B+-Trees (Part 1),COMP171,Main and secondary memories,Secondary storage device is much, much slower than the main RAM Pages and blocksInternal, external sorting CPU operations Disk access: Disk-read(), disk-write(), much more expensive than the operation unit,Contents,Why B+ Tree? B+ Tree Introducti
2、on Searching and Insertion in B+ Tree,Motivation,AVL tree with N nodes is an excellent data structure for searching, indexing, etc. The Big-Oh analysis shows most operations finishes within O(logN) time The theoretical conclusion works as long as the entire structure can fit into the main memory Whe
3、n the data size is too large and has to reside on disk, the performance of AVL tree may deteriorate rapidly,A Practical Example,A 500-MIPS machine, with 7200 RPM hard disk 500 million instruction executions, and approximately 120 disk accesses each second (roughly, 500 000 faster!) A database with 1
4、0,000,000 items, 256 bytes each (assume it doesnt fit in memory) The machine is shared by 20 usersLets calculate a typical searching time for 1 user A successful search need log 10000000 = 24 disk access, around 4 sec. This is way too slow!We want to reduce the number of disk access to a very small
5、constant,From Binary to M-ary,Idea: allow a node in a tree to have many children Less disk access = less tree height = more branching As branching increases, the depth decreases An M-ary tree allows M-way branching Each internal node has at most M childrenA complete M-ary tree has height that is rou
6、ghly logMN instead of log2N if M = 20, then log20 220 5 Thus, we can speedup the search significantly,M-ary Search Tree,Binary search tree has one key to decide which of the two branches to take M-ary search tree needs M-1 keys to decide which branch to takeM-ary search tree should be balanced in so
7、me way too We dont want an M-ary search tree to degenerate to a linked list, or even a binary search tree,B+ Tree,A B+-tree of order M (M3) is an M-ary tree with the following properties: The data items are stored at leaves The root is either a leaf or has between two and M children Node: The (inter
8、nal) node (non-leaf) stores up to M-1 keys (redundant) to guide the searching; key i represents the smallest key in subtree i+1 All nodes (except the root) have between M/2 and M children Leaf: A leaf has between L/2 and L data items, for some L (usually L M, but we will assume M=L in most examples)
9、 All leaves are at the same depth,Note there are various definitions of B-trees, but mostly in minor ways. The above definition is one of the popular forms.,Keys in Internal Nodes,Which keys are stored at the internal nodes?There are several ways to do it. Different books adopt different conventions
10、.We will adopt the following convention: key i in an internal node is the smallest key (redundant) in its i+1 subtree (i.e. right subtree of key i)Even following this convention, there is no unique B+-tree for the same set of records.,B+ Tree Example 1 (M=L=5),Records are stored at the leaves (we on
11、ly show the keys here) Since L=5, each leaf has between 3 and 5 data items Since M=5, each nonleaf nodes has between 3 to 5 childrenRequiring nodes to be half full guarantees that the B+ tree does not degenerate into a simple binary tree,B+ Tree Example 2 (M=4, L=3),We can still talk about left and
12、right child pointers E.g. the left child pointer of N is the same as the right child pointer of J We can also talk about the left subtree and right subtree of a key in internal nodes,B+ Tree in Practical Usage,Each internal node/leaf is designed to fit into one I/O block of data. An I/O block usuall
13、y can hold quite a lot of data. Hence, an internal node can keep a lot of keys, i.e., large M. This implies that the tree has only a few levels and only a few disk accesses can accomplish a search, insertion, or deletion.B+-tree is a popular structure used in commercial databases. To further speed u
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- BTREESPART1PPT
