achieving minimum height for block split tree structured files

10
Inform. .Sysrems Vol. 12, No. 1, pp. 115-124, 1987 0306-4379/87 $3.00 + 0.00 Printed in Great Britain Pergamon Journals Ltd ACHIEVING MINIMUM HEIGHT FOR BLOCK SPLIT TREE STRUCTURED FILES JAMES R. DRISCOLL and SHEAU-DONG LANG Department of Computer Science, University of Central Florida, Orlando, FL 32816, U.S.A and STEPHEN M. BRATMAN Distributed Processing Technology, 132 Candace Drive, Maitland, FL 32751, U.S.A. (Received 3 April 1986) Abstract-In this paper we describe a technique to maintain minimum height for block split tree structured files such as the B-tree and its variants. The technique is not complex and involves negligible overhead. We also model the root node insertion activity for block split tree structured files. Our model enables us to predict the effectiveness of our new technique. We present experimental data to verify our model’s predictions, 1. INTRODUCTION Block split tree structured files [l] such as the B-tree [2] and its variants [3] are file storage techniques which offer, even for very large files, the following main properties: 1. The file can be accessed with a small number of index probes into secondary storage. 2. The space utilization is more than 50%. 3. The index structure is balanced under insertion and deletion using block splitting and concate- nation strategies, respectively. Block split tree structured files predominate in re- lational GDBMS where efficient index management is a subject of current research [4, p. 601. Further- more, block split tree structured files have recently been tied to efficient backup and recovery techniques using differential files [5, 61. But, despite the fact that block split tree structured files are dynamically bal- anced, the index management can be inefficient. Central issues for the management of large tree structured files are the storage space needed to place the keys and the search time to retrieve a key. Modeling efforts have attempted to characterize stor- age space utilization. A characterization of average space utilization has been obtained for the B-tree and its variants [l, 7, 81. However, none of these efforts accurately characterize the space utilization near the root node. In regard to search time, more than the optimum number of accesses are required in many cases. This is due to the fact that the index structure has become higher than it could be. Just one extra level in an index for a very large database could dramatically affect search cost. Some modeling efforts have attempted to minimize index path length. Systems of differential equations such as those found in [9] were developed which provided an algorithm for minimizing index path length of a B-tree. Like- wise, reorganization techniques such as those found in [lo, 111 were developed to minimize index path length. The techniques, while effective, are very com- plicated. Furthermore, the cost of their implemen- tation in practical applications as well as their total operational cost over the lifetime of an actual data- base is questionable. No real studies have been made to support the utility of these techniques. In this paper, we present a simple technique for effectively maintaining a minimum height B + tree (the technique may also be applied to other block split tree structured files). The technique is quite easy to implement and its operational cost is refreshingly insignificant. We then accurately model the root node insertion activity of a B-tree. This modeling effort enables us to predict the effectiveness of our new technique. The organization of our paper is as follows. Back- ground B + tree and file directory information is provided in Section 2. Section 3 provides the proof of a formula for minimum B + tree height. Section 4 outlines our new technique which effectively main- tains minimum B + tree height. Section 5 develops an analytic model of the root node insertion activity and predicts our new technique’s effectiveness. Section 6 presents experimental data which supports our model’s predictions. Section 7 concludes our paper. 2. BACKGROUND INFORMATION A B-tree of order m is a page tree which has the following properties: 1. Every node has at most m children. 2. Every node, except for the root and the leaves, has at least [m/21 children. 115

Upload: james-r-driscoll

Post on 21-Jun-2016

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Achieving minimum height for block split tree structured files

Inform. .Sysrems Vol. 12, No. 1, pp. 115-124, 1987 0306-4379/87 $3.00 + 0.00 Printed in Great Britain Pergamon Journals Ltd

ACHIEVING MINIMUM HEIGHT FOR BLOCK SPLIT TREE STRUCTURED FILES

JAMES R. DRISCOLL and SHEAU-DONG LANG

Department of Computer Science, University of Central Florida, Orlando, FL 32816, U.S.A

and

STEPHEN M. BRATMAN

Distributed Processing Technology, 132 Candace Drive, Maitland, FL 32751, U.S.A.

(Received 3 April 1986)

Abstract-In this paper we describe a technique to maintain minimum height for block split tree structured files such as the B-tree and its variants. The technique is not complex and involves negligible overhead. We also model the root node insertion activity for block split tree structured files. Our model enables us to predict the effectiveness of our new technique. We present experimental data to verify our model’s predictions,

1. INTRODUCTION

Block split tree structured files [l] such as the B-tree [2] and its variants [3] are file storage techniques which offer, even for very large files, the following main properties:

1. The file can be accessed with a small number of index probes into secondary storage.

2. The space utilization is more than 50%. 3. The index structure is balanced under insertion

and deletion using block splitting and concate- nation strategies, respectively.

Block split tree structured files predominate in re- lational GDBMS where efficient index management is a subject of current research [4, p. 601. Further- more, block split tree structured files have recently been tied to efficient backup and recovery techniques using differential files [5, 61. But, despite the fact that block split tree structured files are dynamically bal- anced, the index management can be inefficient.

Central issues for the management of large tree structured files are the storage space needed to place the keys and the search time to retrieve a key. Modeling efforts have attempted to characterize stor- age space utilization. A characterization of average space utilization has been obtained for the B-tree and its variants [l, 7, 81. However, none of these efforts accurately characterize the space utilization near the root node. In regard to search time, more than the optimum number of accesses are required in many cases. This is due to the fact that the index structure has become higher than it could be. Just one extra level in an index for a very large database could dramatically affect search cost. Some modeling efforts have attempted to minimize index path length. Systems of differential equations such as those found in [9] were developed which provided an algorithm

for minimizing index path length of a B-tree. Like- wise, reorganization techniques such as those found in [lo, 111 were developed to minimize index path length. The techniques, while effective, are very com- plicated. Furthermore, the cost of their implemen- tation in practical applications as well as their total operational cost over the lifetime of an actual data- base is questionable. No real studies have been made to support the utility of these techniques.

In this paper, we present a simple technique for effectively maintaining a minimum height B + tree (the technique may also be applied to other block split tree structured files). The technique is quite easy to implement and its operational cost is refreshingly insignificant. We then accurately model the root node insertion activity of a B-tree. This modeling effort enables us to predict the effectiveness of our new technique.

The organization of our paper is as follows. Back- ground B + tree and file directory information is provided in Section 2. Section 3 provides the proof of a formula for minimum B + tree height. Section 4 outlines our new technique which effectively main- tains minimum B + tree height. Section 5 develops an analytic model of the root node insertion activity and predicts our new technique’s effectiveness. Section 6 presents experimental data which supports our model’s predictions. Section 7 concludes our paper.

2. BACKGROUND INFORMATION

A B-tree of order m is a page tree which has the following properties:

1. Every node has at most m children. 2. Every node, except for the root and the leaves, has

at least [m/21 children.

115

Page 2: Achieving minimum height for block split tree structured files

116 JAMES R. DRISCOLL er al.

The root has at least two children. A non-leaf node with j children contains j records, each being a key, pointer pair. All leaves appear at the same level. They are the same as non-leaf nodes except that, instead of pointers, the records contain the data associated with each key and the number of records in a leaf node, m', may be different from m.

the leaf nodes also form a linked list, than the structure is referred to as a B + tree [3] and has been used in, for example, IBM’s VSAM [12, 131 and DEC’s RMS [14]. In this paper the height of a B-tree, h, refers to the number of levels in the tree.

In every file storage scheme which uses B + trees or any other standard file organization technique, there must exist certain directory information about the file which is kept separate from the file data and/or indexes, and yet which is always available to the operating system. The directory information is pri- marily maintained by the operating system and is, except in limited cases, generally unavailable to the user.

In general, directory information contains items such as file name, file creation date, file access type, the last date and time the file was accessed, file size, the physical location of the file, etc. In indexes using structures such as B + trees, where the lowest level of pages is tied together sequentially by use of a linked list, the physical location of the file includes a root page pointer and a pointer to the first page in the

linked list. The directory information is retained in main memory during file access, so there are no extra disk accesses whenever the root page pointer changes during the insertion or deletion process.

It may be worthwhile to point out that the direc- tory information could also include the key of the first record in the root page along with the root pointer. The situation is shown in Fig. 1 which is in part taken from [15] and shows an example of a file directory entry for a B + tree. The example also indicates that the format of the first record in each index page is a key, pointer pair just like the format of the other records in an index page. This is the case for IBM’s VSAM [12,13] and DEC’s RMS [14]. Textbooks usually omit the detail of file directories and the key values of the first record in an index page, but the detail is present in actual B f tree imple- mentations.

The main purpose of this section has been to emphasize that a single file directory entry is much more extensive than just the name of the file and a pointer to the file. In fact, a single file directory entry is a rather sizable amount of information and could also include a key value. This information will be useful in Section 4 where we describe a technique to maintain minimum height B + trees.

3. FORMULA FOR MINIMUM B + TREE HEIGHT

In this section we present a formula for minimum B + tree height. Equivalent formulae do not appear

1

File Creation Access Last File Sequential Lowest Root Other

Name Date Type Access Size Pointer Key Pointer

T 1 t

Second Record

Fig. 1. Textbook B + tree with file system directory information (taken in part from 1151).

Page 3: Achieving minimum height for block split tree structured files

B&k split tree structured files 117

in the literature, but a formula for the B-tree has been reported in [7-9, 1 if, However, their results are more complex because of the fact that in a B-tree, both keys and data appear in the internal nodes of the tree. The formula presented here is very useful for manual verification of the experimental data in Section 6.

Theorem 1

Let T be a B + tree of order m and height h, h 2 1. Let m’ be the maximum number of records in a leaf page. Suppose T contains N leaf records and T is at minims height. Then

h=l+ [log, [-$I 1.

Proof. First, it is easy to see that N 5 mh- ’ ‘rn ’ because mh- ’ ’ m is the largest number of leaf records in a B + tree of height h. Hence N/m’ 2 mh- I. Notice that mh-’ is an integer. Hence, this last inequality implies

N 11 < mh-‘. 2 -

Taking the logarithm of both sides, we obtain

N log, 2 Ih-1.

r 1

Hence rlog,,,rN/m’ll I h - 1 because h - 1 is an integer. Therefore,

To complete the proof, we now need to show

Notice that since the B + tree Tis at minims height, its total number of leaf records, N, must be strictly greater than mh - ‘. m ‘, the largest number of leaf records in a B + tree of height h - 1. That is,

N > mh-‘.m’.

Dividing both sides by m’ and applying the ceiling operator, we obtain

N c 1 2 > mhe2

Taking the logarithm and again applying the ceiling operator yields

That is,

because the left term is an integer. Therefore

hsl+ [log,,, [-$I 1.

Combining this with the previous inequality, we have proved the theorem.

Care must be taken to use this formula in a computer program to detect a violation of minimum height, the reason being that computer round-off errors could cause miscalculation of the ceiling func- tion. A more appropriate method to detect a vio- lation of minimum height within a computer program would be to check against the largest number of leaf records for possible heights.

4. MINIMUM HEIGHT B + TREE

We now present a technique to keep a B + tree at minimum height by first describing an extension to the B + tree file directory entry discussed in Section 2, and then outlining new B + tree file insertion and deletion algorithms which make use of the extension.

Let a B + tree file directory entry be the following extension to the directory entry shown in Fig. 1:

/ File . . .

7-7r--y Sequential Key1 j Ptrl Key21 Ptr2 /Otheri

13 Pointer 1 I I 1._-.-- I .1.._. ._.J

where (keyl, ptri) and (key2, ptr2) have replaced (lowest key, root pointer). In this extension, key 1 is the key of the first record in the page pointed to by ptr 1 and key2 is the key of the first record in the page pointed to by ptr2. The interpretation is that (keyl,ptrl) and (key2,ptr2) are B + tree root page pointers, and the largest key in the B + tree pointed to by ptrl is less than keyf. This extension could be generalized to incorporate three or more key, pointer pairs in the file directory entry.

The following outlines insertion and deletion algo- rithms which use this extension to maintain a B + tree so that it is effectively of minimum height.

New insertion algorithm

Let y be the key of a new main file record. Then there are two cases to consider:

(Case I) Only (keyl, ptrl) are present (they may be null in the case of an empty tree). 1. Insert y into the B + tree pointed to by ptrl. 2. If the page pointed to by ptrl splits and the new

height would be greater than the mir~imum height then establish (key], ptrl) and (key2, ptr2) for the two new pages instead of creating a new root page.

3. If the page pointed to by ptrl splits and the new height is equal to the minimum height then establish (keyl, ptrl) for the new page.

(Case II) Both (keyl, ptrl) and (key2, ptr2) are present. 1. If y belongs to the B + tree pointed to by ptrl

then do the following: (a) Insert y into the B + tree pointed by ptrl.

IS. 12/l-I

Page 4: Achieving minimum height for block split tree structured files

118 JAMB R. DRISCOLL et al.

(b) If the page pointed to by ptrl splits then create a new root page for the two new pages, also place (key2, ptr2) in that new page, establish (keyl, ptrl) for the new page, and make (key2, ptr2) null.

2. If y belongs in the B + tree pointed to by ptr2 then do the following:

(a) Insert y into the B + tree pointed to by ptr2. (b) If the page pointed to by ptr2 splits then

create a new root page for the two new pages, also place (keyl, ptrl) in that new page, establish (keyl, ptrl) for the new page, and make (key2, ptr2) null.

New deletion algorithm

Let y be the key of the B $ tree main file record to be deleted. Then there are two cases to consider:

(Case I) Only (keyl, ptrl) are present (they may be null in the case of an empty tree). Delete y from B + tree pointed by ptrl. This may cause (keyl, ptrl) to change.

(Case II) Both (keyl, ptrl) and (key2, ptr2) are present.

1. If y belongs in the B + tree pointed to by ptrl then delete y from the B + tree. If this causes underflow in the page pointed to by ptrl, then use the standard deletion strategy of borrowing from the page pointed to by ptr2. If the page pointed to by ptrl underflows and borrowing is not possible then do the following: (a) Concatenate it with the page pointed to by

ptr2. (b) Establish (keyl, ptrl) for the concentrated

page. (c) Make (key2, ptr2) null.

2. If y belongs in the B + tree pointed to by ptd then delete y from the B + tree. If this causes underflow in the page pointed to by ptd, then use the standard deletion strategy of borrowing from the page pointed to by ptrl. If the page pointed to by ptr2 underflows and borrowing is not possible then do the following: (a) Concatenate it with the page pointed to by

ptrl. (b) Establish (keyl, ptrl) for the concatenated

page. (c) Make (key2, ptr2) null.

Figure 2 provides an example for the New In- sertion Algorithm (Case I). In the figure, the main fife record with key “efe” is inserted into a B + tree which originally has only one root page. A normal insertion algorithm would have yielded a B + tree of height h = 3. Since a minimum height B + tree for nine main file records has height h = 2, our new technique effectively maintains a B + tree of height h = 2 by using two root pages.

Note that although the additional root entry in the

file directory eliminates the increase in tree height, sooner or later one of the two root pages pointed to by our root pointers will become full and split. When this happens during Insertion (Case II), our technique will revert back to one key, pointer pair in the file directory and the height of the B + tree will, of course, increase. Clearly, this technique increases the height of a B + tree during the root insertion event which causes the new root page to have three chil- dren, or when the new root page has two children and the new B + tree height is minimum. In the next section we develop an analytic proof of the effec- tiveness of the new insertion and deletion algorithms by deriving formulae predicting the root insertion event.

5. PREDICTING THE ROOT INSERTION EVENT

In this section we consider a B + tree and we assume it has just increased in height. We derive formulae for the expected number of insertions which cause the third and fourth entries into the B + tree root page. These formulae also apply to B-trees and may be modified for other block split tree structured files. These formulae are then used to predict the effectiveness of the minims height B + tree algo- rithms in Section 4.

Theorem 2

Let T be a B + tree of order m. Let m’ be the maximum number of records in a leaf page. Suppose an insertion has just caused T to increase to height h (h L 2), where h is the number of levels in the B + tree and the root is at level 1. Then the following formulae give the expected number of level 2 entries at the time the root page receives its third and fourth entries.

& = the expected number of level 2 entries at the time the root page receives its third entry

;Y(m+l) 2- 1

( 1

m+l ’

r 7C-

2 E4 = the expected number of level 2 entries at the time the root page receives its fourth entry

=(m-t-1) 2+ 1

( J-1

m+l ’ A-

2 Proof. When the tree T has just increased its height,

there are exactly two pages at level 2 [call them B, and B2, and call the root page B,). Let r = (m + 1)/Z which is the (average) number of entries in each of the pages B, and Bs. Suppose new entries are now inserted into the B + tree T uniformly distributed between two subtrees at B, and B2, let us define the following random variables:

X = the total number of inserts until one of B, or B2 splits.

Y = the total number of inserts until both B, and Bz have split.

Page 5: Achieving minimum height for block split tree structured files

Block split tree structured files 119

File System Directory

File Name

“hot”

Root Page Polnter c

null

Root Page Pointer

* Root Page -

BECOMES

- Root Pages -

Fig. 2. Example of insertion (Case I). Leaf record with key “efe” in inserted into a B + tree which has only one root page.

Assuming the uniform distribution, we obtain the following distributions for X and Y:

Prob [X = r + k] =

otherwise

where the term

represents the probability that the rth “success” (i.e. either B, or B2 receives its rth insert, whichever comes first) occurs at the “trial number” r + k (i.e. r + k total inserts), and this follows the well-known nega- tive binomial distribution [16, p. 1551. (Note that

:?12( r+k-1 k )(~!‘k=~~~Prob[X=r+k]= 1.

because this is the sum of the probability distribu- tions of X. This identity will be used later in the

proof.) Similarly, we obtain (approximately)

Prob [Y =2r +k]=

~2.(2*:k;1).(~~+k, for k a0

0

where the term

otherwise

represents the probability that the rth “success” (i.e. either B, or Bz receives its rth insert, whichever comes later) occurs at the “trial number” 2r + k (i.e. 2r + k total inserts). Note that the above probability distri- bution for Y is only approximately accurate, because this distribution assumes that the entries are inserted uniformly between the subtrees at B, and B,, even after one of them splits, until the other also splits.

By the definition of X and Y, the expected value of X gives the expected number of inserts into the B + tree T until the third entry is added to its root page B,,; similarly, the expected value of Y gives

Page 6: Achieving minimum height for block split tree structured files

120 JAMES R. DRISCOLL et al.

(approximately) the expected number of inserts until the fourth entry is added to the root page $. Now we compute the expected values E[X] and E[Y] as follows:

E[X)= C( +k)2 :rl r (’ ‘i - l)(i)+’ by definition

= 23 3(;>“’

because(r+k)(r’kk-‘)=~.(r:k)

=2r[j0(r :“>(;>“‘-(zr’)(;>“]

=2r[l-(~)(;>“] because the summation

term adds up to I as noted before

z2r 1-I ( ) Jnr

by applying Stirling’s formula [16, p. SO].

Similarly,

E[Y]= f (2r+k)2 k-0

‘2r.~o(~-3;)b+k

because(2r+k)(2r:_k[‘)

cr.

Note that

E[Xj+E[Y]=2rC :;:(r ;“)(;>“’

+2:~o(:‘++kk)(;)ll+k

=2$ r;i ; ‘+I ,=O ( )()

=4r(~>'+'~o(r:i)(~)

=4r.(;)"'(l-y""

by the Binomial Theorem

= 4r

Combining this with the expression for E[X] yields

E[Y]z2r ( > 1+J--- . fi Therefore

E, = the expected number of level 2 entries at the where U is the average space utilization for pages at

time the root page receives its third entry

=5(m + l)+E[X]

z((m+l) 2- l

i ii

m+l 77-

2 and

Ed = the expected number of level 2 entries at the time the root page receives its fourth entry

z(m + I)+ E[Y]

%(m+l) 2-t ’

( J-I

m+l ?t-

2

We will now use the results of Theorem 2 to prove the effectiveness of the algorithms in Section 4. Recall that Case II of the new B + tree insertion algorithm in Section 4 is the only time when a B + tree increases height. The following corollaries derive conditions which mean that (on the average) the B + tree built by the new insertion algorithm is of minimum height.

Corollary 3

Consider the new insertion algorithm with file directory entries containing two key, pointer pairs. Let T, and T, be B + trees of order m pointed to by (key 1, ptrl) and (key2, ptr2), respectively. Let h be the height of T, and T,; this is the number of levels in a tree and the root is at level 1. Let m’ be the maximum number of records in a leaf page. Suppose an insertion causes the root page of T, or T, to split. (This occurs in Case II of the new insertion algo- rithm.) Now the two key, pointer pairs for T, and T, are replaced by one key, printer pair for a B + tree, T, of height h + 1. Then the following condition implies that (on the average) T is at minimum height:

m+l 2_ I

-i /-I

iP’>l 7 m m+l

x- 2

where U is the average space utilization for pages at levels greater than 2.

Proof. Note that the time either T, or T2 splits, causing the B + tree T to increase its height to h + 1, is exactly when a “normal” B + tree of height h + I receives the third entry into its root page. Therefore, the B + tree T is (on the average) at a minimum height if the following condition holds:

The expected number of entries in T > the max- imum number of entries in a B + tree of height h.

According to the previous theorem, the expected number of entries in T when the root page receives its third entry is

WJ)*-WW,

Page 7: Achieving minimum height for block split tree structured files

Block split tree structured files 121

levels greater than 2. Therefore, the above condition for T to be of minimum height becomes

which simplifies to

m+l 2_ 1

-( J-1

V-i > 1. m m+l

7X----- 2

Suppose three key, pointer pairs are used in the new insertion algorithm. Then the following condi- tion implies that (on the average) the B + tree is at minimum height:

!%!I! 2+

m ( d-1 A+, Uh_‘>l,

7t- 2

where m, U, h have the same interpretation as in Corollary 3.

Proof. The proof is similar to that of Corollary 3. We wish to note that if the new technique is applied

to a B* tree (which is another type of block split tree structured tile), then an analysis of our new technique with two key, pointer pairs yields the following condition for the B* tree to be (on the average) at minimum height:

2m + 1 V-i > 1.

m

For space reasons, we do not include the analysis here.

For the conditions derived in Corollaries 3 and 4, we will examine situations where h = 2, h = 3, and h = 4. Note that h = 1 is not considered because a B -I- tree of height 1 will be at minimum height when its height increases to 2. By examining situations where h = 4, we are allowing a B _t tree to grow to height 5. For practical purposes, a B + tree rarely exceeds a height of 5. In addition, the order of the I3 f tree reasonably lies between 8 and 128.

We will also examine situations where the space utilization, U, lies between 69% and 83%. These two percentages represent the two extremes of space utilization discussed in [l, 81 where it is pointed out that U for a B + tree is 69% and U for a modified B* tree is 83%.

The graphs in Fig. 3 plot the values of the expres- sions

CL! 2-

m

t J-1

;+, u”-’

7C- 2

and

2.0

1.5

1.0

0.5

h=2

3 pointers

z 0

LEGEND

2 pointers 3 pointers

l :me8 o:m=8

+:m=12a A :m:zo

0 :m=128

I I I I I I I I I I I I I I I

69 71 73 75 77 79 81 83

u (%)

(a)

h=3

1.5

1.0

2 pointers 3 pointers

l : m=B CI : m=8

.t :m=128 * : m=20

o:m=128

0.5

2.0

I I i I ! I I I I I I I I I i

69 71 73 75 77 79 81 83

u (%I

@I

h=4

LEGEND

2 pointers 3 pointers ~ ~ . :m=8 q :m=8

$ :m=128 A :m=20 0 :m=128

I

3 pointers

1 pokers

0.5

111111111111111

69 71 73 75 77 79 81 83

U(%)

(c)

Fig. 3. Plots of the expressions of two pointers and three pointers.

Page 8: Achieving minimum height for block split tree structured files

122 JAMB R. DRISCOLL et al.

for the new insertion technique of Section 3 using two key, pointer pairs and three key, pointer pairs re- spectively.

Examination of the graphs in Fig. 3 indicates the following:

For the condition of two key, pointer pairs, the influence of m on being in a “safe region” or “unsafe region” is negligible. For low storage utilization (near that of a B + tree), the only “safe region” satisfying the condition of two key, pointer pairs is when the height is allowed to increase from 2 to 3 but no higher. For the condition of three key, pointer pairs, a smaller m causes operation in a “safe region.” For high storage utilization (near that of a modified B*tree [1]), two key, pointer pairs are sufficient for operation in a “safe region” for any tree height up to 5 and any tree order, m.

6. EXPERIMENTAL DATA

In this section, we show the result of an experiment where B + tree files are initially empty and built up to 5 levels by random insertions. The experiments were performed on a VAX 1 l/780 running Unix. All data collected is the average of 30 separate insertion sequences for a B + tree file where the leaf nodes contained a maximum of 16 lo-character keys, and the non-leaf nodes contained a maximum of 15 key, pointer pairs. Figures 4-6 plot the average number of records in the B + trees when key, pointer pairs were inserted into the root nodes. These figures represent the average performance of a B -I- tree as it grows from height 2 into height 3 (Fig. 4), height 3 into height 4 (Fig. 5), and height 4 to height 5 (Fig. 6).

l;lIIIIIIIIIIIIIII 2 4 6 6 10 12 14 2 4 --\

h=2 h=3

NUMBER OF POINTERS IN ROOT NODE

Fig. 4. B + tree performance from height 2 into height 3.

3000

If? k 2500

ti .s

2000

g

?i g 1500 IY

d + 1000

e

500

2 4 6 8 1012 14 2 4

h*3 h=4

NUMBER OF POINTERS IN ROOT NODE

Fig. 5. B + tree performance from height 3 into height 4.

The largest number of records that can be stored in our B + trees when they are at height 2 is 240. The data in Fig. 4 shows that an average B + tree is of height 3 after insertion of 176 total records. During the time between an empty tree and 240 total records, an average B + tree is one level too high 27% of the time

240 - 176

240

thus increasing access time by 50%.

35,000

30,000 1

:: ki 25,000

I E t

5000

Iilllllrllllllllll 2 4 6 6 10 12 14 2 4

h=4 h=5 NUMBER OF POINTERS IN ROOT NODE

Fig. 6. B + tree performance from height 4 to height 5.

Page 9: Achieving minimum height for block split tree structured files

Block split tree structured files 123

According to the predictions in Fig. 3 for h = 2, m = 15, and U = 69%, the assumption of two root pointers in the file directory should yield operation in the “safe region” (i.e. a B + tree is never too high). The data in Fig. 4 supports this prediction by show- ing that an average B + tree would remain at height 2 until insertion of 325 (which is > 240) total records. Consequently, an average B + tree would never be too high. This benefit is achieved without the cost of maintaining a minimum height B + tree as in [lo]. As an extra benefit, during the time between an empty tree and insertion of 325 total records, an average B + tree would effectively be one level lower than the minimum height 26% of the time

325 - 240

325

thus reducing access time by 33%.

The largest number of records that can be stored in our B + trees when they are at height 3 is 3600. The data in Fig. 5 shows that an average B + tree is of height 4 after insertion of 1824 total records. During

the time between an empty tree and 3600 total records, an average B + tree is one level too high 51% of the time

(3600 - 182;;;o(240 - 176) = 51%

>

)

thus increasing access time by at least 33% (50%

between 170 total records and 240 total records, and 33% between 1824 total records and 3600 total records).

According to the predictions in Fig. 3 for h = 3,

m = 15, and CT = 69%, the assumption of two root pointers should yield operation in the “unsafe region”, while the assumption of three root pointers should yield operation in the “safe region”. The data in Fig. 5 support this prediction by showing that an average B + tree would remain at height 3 until insertion of 3330 (which is <3600) total records for two root pointers and 3872 (which is >3600) total records for three root pointers. Consequently, an average B + tree would never be too high if three root pointers are assumed. There is a small extra benefit between 3600 total records and 3872 total records. This is when an average B + tree would effectively be one level lower than the minimum height.

The largest number of records that can be stored in our B + trees when they are at height 4 is 54,000. The data in Fig. 6 shows that an average B + tree is of height 5 after insertion of 17,951 total records. During the time between an empty tree and 54,000 total records, an average B + tree is one level too high 70% of the time

(54,000 - 17,951) + (3600 - 1824) + (240 - 176)

54,000

thus increasing access time by at least 25%.

According to the predictions in Fig. 3 for h = 4, m = 15, and U = 69%, the assumption of two or

three root pointers should yield operation in the “unsafe region”. Due to limited computing time we were unable to run our experiment to obtain data verifying this prediction. However, we believe it would have been verified and we feel that four root pointers would have been necessary to effectively maintain the B + trees in this experiment at minimum height.

It is important to point out that, according to Fig. 3, block split tree structured files with higher space utilization (e.g. a B*tree) would permit operation in the “safe region” using two root pointers for any height less than 6. In other words, minimum height for block split tree structured files could be achieved

with nominal overhead using the multiple root pointer technique described in Section 4.

7. CONCLUSION

In this paper, we provided a formula for minimum B + tree height and we described a rather simple technique for effectiverly maintaining a minimum height B + tree. Our technique can be generalized to other block split tree structured files. We also accu- rately modeled the root node insertion activity of a B + tree tree. This model enabled us to predict the effectiveness of our new technique. We presented experimental data to verify our model’s predictions.

Our technique for effectively maintaining a min- imum height B + tree was presented assuming two B + tree root pointers in a file directory entry. As stated, the technique can be generalized to incorpo- rate more than two B + tree root pointers in a file directory entry and it could be applied to other block split tree structured files such as the B*tree. When our technique is applied to block split tree structured files with high space utilization, minimum height can be achieved with two root pointers for any reasonable

tree height. It is important to note that our new technique

provides savings (without overhead) during Case I of the new insertion algorithm because during this time, an increase in the height has been delayed. This situation is similar to the experiments performed in [lo] where an expensive reorganization was used to delay an increase in tree height.

Our model in Section 5 predicts the expected performance of our new technique to effectively maintain a minimum height B + tree. However, an

analysis for confidence intervals is needed to better assess the information displayed by the charts in Fig. 3. Another direction for research would be to perform a cost analysis of our new technique for an operation which may enter “unsafe regions”.

REFERENCES

[1] T. Nakamura and T. Mizoguchi, An analysis of storage utilization factor in block split data structuring scheme. Proc. 1978 VLDB Conf., pp. 489495 (1978).

Page 10: Achieving minimum height for block split tree structured files

124 J- R. DRISCOLL et al.

[2] R. Bayer and E. McCreight, Organization and mainte- nance of large ordered indexes. Acta Inform. 1,173-189 (1972).

[3] D. Comer, The ubiquitous B-tree. Ass. Comput. Mach. Comput. Surv. 11, 121-138 (1979).

[4] A. Cardenas, Data Base Management Systems, 2nd edn, Allyn & Bacon, Newton, MA (1985).

[5] S. D. Lang, J. R. Driscoll and J. H. Jou, Improving the differential file technique via batch operations for tree structured file organizations. 2nd Annuuf IEEE Data Engineering Confr 524-532 (1986).

161 S. D. Lana. J. R. Driscoll and J. H. Jou, Batch insertion L ’ for tree st;uctured file organizations-improving differ-

ential database representation. Inform. Systems 11(2), 167-175 (1986).

[7] R. E. Miller, N. Pippenger, A. L. Rosenberg and L. Snyder, Optimal 2, 3-trees. SIAM J. Comput. 8(l), 42-59 (1979).

[8] A. C. Yao, On random 2-3 trees. Acta Inform. 9, 159-170 (1978).

r91

WI

vu

U21

[131

I141

1151

1161

K. H. Quitzow and M. R. Klopprogge, Space utiliza- tion and access path length in B-trees. Inform. Systems 5(l), 7-16 (1980). E. Gudes and S. Tsur, Experiments with B-tree reor- ganization. Proc. 1980 Ass. Comput. Mach. SIGMOD Conf, pp. 200-206 (1980). A. L. Rosenberg and L. Snyder, Time and space optimality in B-trees. Ass. comput. Mach. Trans. Data- base Systems 6(l), 174-193 (1981). OSlVS Virtual Storage Access Method (VSAM) Logic, Armonk, NY, IBM, Order No. SY26-3841. OS/VS Virtual Storage Access Method (VSAM) Plan- ning Guide. Armonk, NY, IBM, Order NO. GC26-3799. RMS-I I User’s Guide. Digital Equipment Corporation (1979). J. D. Ullman, Principles of Database Systems, p. 63. Computer Science Press, Rockville, MD (1982).- W. Feller, An Introduction to Probability Theory and Its Applications, Vol. 1,2nd edn. Wiley, New York (1957).