Computer method and system for b-tree optimization

Abstract: A B-tree optimizer mechanism is provided for optimizing a B-tree stored in a storage device of a computer system. The B-tree optimizer monitors the type and amount of activity occurring within the B-tree. Based upon the type and amount of activity, the B-tree optimizer determines whether the B-tree should be reorganized. When it is determined that the B-tree should be reorganized, the B-tree optimizer computes an optimal fill factor for the pages within the B-tree, and reorganizes the B-tree by filling each page with key values according to the optimal fill factor.

Description: Technical Field This invention relates generally to a computer method and system for storing data, and more particularly, to a computer method and system for B-tree optimization. Background of the Invention Conventional storage structures, such as the well known B-tree, are used to quickly locate specific units of data (such as data records in a database or files in a directory) stored on a secondary storage device. A B-tree provides a means of clustering pointers to units of data, so that the units can be quickly located. Figure 1 is a block diagram of a conventional B-tree 100 storing a database index. The B-tree 100 has a root node 101, internal nodes 102, 103, 104, and leaf nodes 105, 106, 107, 108, 109, 110, 111, 112, 113. The root node 101 is the node at the top of the tree 100, the leaf nodes 105, 106, 107, 108, 109, 110, 111, 112 and 113 are those at the bottom of the tree, and the internal nodes 102, 103 and 104 are all of the nodes in between the root node and the leaf nodes. The root node 101 contains one or more key values and two or more pointers to internal nodes 102, 103 and 104. Each internal node 102, 103 and 104 contains one or more key values and two or more pointers to lower level internal nodes or leaf nodes 105, 106, 107, 108, 109, 110, 111, 112 and 113. Each leaf node 105, 106, 107, 108, 109, 110, 111, 112 and 113 contains key values and pointers to units of data indexed by the key values. For example, the leaf node 107 contains a key value "40" and a pointer 118 to a data record 119 that corresponds to the key value "40." Nodes are considered parent nodes to nodes to which they point in the next lower level, which are considered child nodes. Leaf nodes have no child nodes. For example, the internal node 102 is a child node to the root node 101, and a parent node to the leaf nodes 105, 106, 107. In order to clarify how searching is performed in a B-tree, it is helpful to consider an example. Suppose the B-tree of Figure 1 is an index to a database file and the key values in each node correspond to a key value field in a data record of the database file. To locate a data record having a key value of "40", a searching routine follows pointer 114 from the root node 101 to the internal node 102. Next, the searching routine follows pointer 117 from the internal node 102 to leaf node 107. The searching routine then searches through key values in leaf node 107 until the key value "40" is found. Finally, the searching routine follows pointer 118 from leaf node 107 to data record 119. For a comprehensive discussion of B-trees and B-tree maintenance algorithms, see Cormen, Introduction to Algorithms (The MIT Press 1991), pp. 381-399. Because a B-tree is stored in secondary storage and data is typically transferred from secondary storage to main memory one page at a time, a common optimization is to have each node in the B-tree occupy an entire page. This way, only one secondary storage access is required to read all of the key values in a node. When a node is allowed to occupy an entire page, key values and pointers are added to the node until the node and page are full, i.e., there is no space available in the page. To add a key value to a node that is full, the node is divided into two nodes (each node containing one half of the key values and pointers), an additional page is allocated to the B-tree, and one of the two nodes is stored on the new page. The other node is stored on the additional page. A key value and a pointer to the other node are added to the parent node of the node that was split. When the parent node becomes full, the parent node is also split using the same technique. Splitting can propagate all the way to the root node, creating a new level in the B-tree whenever the root is split. Attempting to add one key value to a node that is full will cause a page split, leaving the B-tree with two pages that are half empty. Normal activity in a B-tree includes the addition and the deletion of key values. As explained briefly above, key value additions can cause additional pages to be added to the B-tree. The additional pages do not always contain the maximum number of key values possible, thus wasting valuable storage space. Additionally, key value deletions can leave pages with a less than optimal number of key values stored on them. D. Motzkin, Database performance optimization, AFIPS 1985 National Computer Conference, July 15-18, 1985, Chicago US, AFIPS PRESS, Reston, US, pages 555-556 describes a generalized model of the optimization for relational databases, that has been development and implemented. The model is more general and more complete than former models. It consists of a set of algorithms and cost equations, and its output is an optimal set of indices for all fields of all files in the database, It also determines which fields should not be indexed. It allows the user to indicate indices to be evaluated and it takes into consideration periodic reorganization, a variety of transaction types and the multifield/ multifile effects of some transaction types. It distinguishes between dense and nondense attributes, between primary and secondary fields, and between sorted and unsorted files. The optimal physical database configuration produced by the model is generated so that it can work within reasonable system constraints of time and space E. Haq et al, New algorithms for balancing binary search trees, 1988 IEEE SOUTHEASTCON, April 11-13, 1988, Knoxville, US, pages 378-387 describes a simple iterative algorithm for balancing an arbitrary binary search tree in linear time. An efficient parallel algorithm is developed for the iterative algorithm using shared memory model. The number of processors used is equal to N, the number of nodes in the tree. The proposed algorithm has a time complexity of O(1). Collecting bucket index statistical data with colocation considered, IBM Technical Disclosure Bulletin, New York, US, May 1993, vol. 36, no. 5, pages 1-3 discloses a method of collecting statistics on tuple access data in a distributed database system when a "Bucket Index" is used. A tuple is a record in a database; tuple access data refers to various statistics that may be kept about access to the database. A Bucket Index has been used, in distributed database systems, to archive and manage the physical storage location/ node of database tuples; additionally the Bucket Index may be used to implement colocation. Since statistical information is kept at the bucket level and more than one table can use the same bucket map, bucket map statistics reflect access information for more than one table. As table management operations are performed, tuples may be moved from one physical storage node to another. It is the object of the invention to provide an improved method and an improved system for optimizing storage of a B-tree. This object is solved by the method as claimed in independent claim 1 and by the system as claimed in independent claim 8. Preferred embodiments of the invention are subject-matters of dependent claims. In accordance with the present invention, a method is executed in a computer system having a central processing unit for executing instructions and a storage device for storing information. In accordance with this method of the present invention, code is provided for a B-tree optimizer. The B-tree optimizer monitors activity occurring within a B-tree. Activity includes the addition and deletion of key values from the B-tree. After monitoring the amount and type of activity occurring within the B-tree, the B-tree optimizer determines whether the B-tree should be reorganized. When it is determined that the B-tree should be reorganized, the B-tree optimizer computes an optimal fill factor for the pages of the B-tree. The optimal fill factor is a percentage that each page in the B-tree should be filled depending upon the amount and type of activity previously detected in the B-tree. After computing the optimal fill factor, the B-tree optimizer reorganizes the B-tree. The B-tree optimizer uses several methods to determine whether the B-tree should be reorganized. One method includes determining that the B-tree should be reorganized when the B-tree comprises a minimum number of pages and a substantial amount of page additions and page deletions has occurred within the B-tree in a given period of time. Another method includes determining that the B-tree should be reorganized when an amount of time since the last reorganization is greater than a minimum amount of time and a substantial number of key value deletions has occurred. Yet another method includes computing an optimal fill factor for the B-tree, and then determining that the B-tree should be reorganized when the amount of time since the last reorganization is greater than a minimum amount of time and the actual fill factor is greater than a previously determined fill factor. Brief Description of the Drawings Figure 1 is a block diagram of a convention B-tree. Figure 2 is a block diagram of a preferred embodiment of a computer system for practicing a preferred embodiment of the present invention. Figure 3 is an overview flow diagram of a method used by the preferred embodiment to optimize a B-tree. Figures 4A-4C comprise a detailed flow diagram of a method used by the preferred embodiment to determine whether a B-tree should be reorganized. Figure 5 is a detailed flow diagram of a method used by the preferred embodiment to determine an optimal fill factor for a B-tree. Figure 6 is a detailed flow diagram of a method used by the preferred embodiment to reorganize a B-tree in accordance with an optimal fill factor. Detailed Description of the Invention A preferred embodiment of the present invention provides a B-tree optimizer mechanism for automatically reorganizing a B-tree in accordance with the amount and type of activity (such as the addition and deletion of key values and pages) occurring in the B-tree. Based upon the amount and type of activity in the B-tree over a certain period of time, the B-tree optimizer determines an optimal amount that the pages in the B-tree should be filled before a page split occurs, and then reorganizes the B-tree so that each page is filled the determined optimal amount. The amount each page is filled is referred to as the fill factor of the B-tree. Figure 2 is a block diagram of a preferred embodiment of a computer system 200 for practicing the preferred embodiment of the present invention. This computer system 200 is merely illustrative and should not be viewed as restricting the present invention. Those skilled in the art will know other suitable computer system configurations for practicing the present invention. The computer system 200 comprises a secondary storage device 201, a random access memory (RAM) device 202, a central processing unit (CPU) 203, an input device 204, and an output device 205. When invoked, the B-tree optimizer provided by the present invention is loaded into the RAM device 202. The secondary storage device 201 is preferably some kind of disk system. The amount of activity in B-tree in a certain period of time determines whether the B-tree is "static" or "dynamic." A static B-tree is one that does not have many key values added or deleted during the time period, while a dynamic B-tree is one that has many key values added or deleted during the time period. Because page splits do not occur very often in a static B-tree, an optimization is to have each page in the static B-tree contain as many key values as possible. By storing as many key values as possible on each page, the static B-tree will require a smaller amount of storage space. Conversely, because many key value additions and deletions occur in a dynamic B-tree, an optimization is to have each page in the dynamic B-tree contain just enough key values so that new key values may be added without the pages being split too often. The B-tree optimizer provided by the preferred embodiment of the present invention takes into account whether a B-tree is static or dynamic when it computes an optimal fill factor. To determine whether a B-tree is static or dynamic, the B-tree optimizer must have access to activity statistics regarding the amount and type of activity occurring within the B-tree. In the preferred embodiment, B-tree maintenance algorithms provide activity statistics such as those listed below in Table A. These activity statistics are stored in a special block in the root node of the B-tree. When the B-tree optimizer is invoked, it is passed a pointer to the special block containing the activity statistics. 1. Number of pages in the B-tree. 2. Number of pages added since last reorganization. 3. Number of pages deleted since last reorganization. 4. Time of last reorganization. 5. Number of key values deleted since last reorganization. 6. Fill factor at time of last reorganization. The activity statistics listed above in Table A may be obtained using counter variables. That is, every time a new page is added to the B-tree, a page counter is incremented. Those skilled in the art will appreciate that the activity statistics may be gathered using other methods. In the preferred embodiment, the B-tree optimizer is invoked whenever a key value is added to or deleted from the B-tree. Those skilled in the art will recognize that other events may trigger the B-tree optimizer. The B-tree optimizer optimizes a B-tree by performing the steps shown in the flow diagram of Figure 3. In step 302, the B-tree optimizer checks the activity statistics for the B-tree. As mentioned previously, when the B-tree optimizer is invoked it is passed a pointer to the activity statistics stored in the root node of the B-tree. After checking the activity statistics for the B-tree, in step 304 the B-tree optimizer determines whether the B-tree should be reorganized. Those skilled in the art will appreciate that many different methods can be used to determine whether the B-tree should be reorganized. The methods used in the preferred embodiment to determine whether the B-tree should be reorganized are described in more detail below with reference to the flow diagram of Figures 4A-4B. If the B-tree optimizer determines that the B-tree should not be reorganized, then the process ends until the B-tree optimizer is again invoked. If the B-tree optimizer determines that the B-tree should be reorganized (step 304), then in step 306 the B-tree optimizer computes the optimal amount that the pages in the B-tree should be filled based upon the amount and type of activity occurring within the tree. This amount is expressed in terms of a percentage and is referred to as the fill factor. The method used in the preferred embodiment to compute the optimal fill factor is described in detail below with reference to the flow diagram of Figure 5. After determining the optimal fill factor (step 306), in step 308 the B-tree optimizer reorganizes the B-tree in accordance with the computed optimal fill factor. The method used in the preferred embodiment to reorganize the B-tree is described below with reference to the flow diagram of Figure 6. It is helpful to review the steps performed by the B-tree optimizer to determine whether the B-tree should be reorganized. The flow diagram of Figures 4A and 4B lists the steps used in the preferred embodiment to determine whether a B-tree should be reorganized. The method begins with a trivial test to determine if the B-tree includes more than one page, and then continues on to more substantive tests that take into consideration whether the B-tree is static or dynamic. Beginning with step 402, if the B-tree optimizer determines that the root node of the B-tree is also a leaf node (i.e., the B-tree includes only one page), then the B-tree optimizer determines that the B-tree does not need to be reorganized. This determination is made without consideration of activity occurring within the B-tree. The B-tree optimizer can quickly determine whether the root node is a leaf node because each node has a flag that is set to indicate whether or not the node is a leaf node. If the root node of the B-tree is not a leaf node, then the B-tree optimizer proceeds with a series of tests to determine whether the B-tree should be reorganized. The first test used in the preferred embodiment to determine whether the B-tree should be reorganized depends upon the number of pages in the B-tree and the amount of activity that has occurred in the tree since the last reorganization. In step 406, the B-tree optimizer determines the total number of pages in the B-tree. This information may be obtained from the activity statistics stored in the root node of the B-tree. In step 408 the B-tree optimizer determines the number of pages added to and deleted from the B-tree since the last reorganization occurred. This information is preferably obtained from the activity statistics stored in the root node of the B-tree. The time period used when measuring the number of pages added or deleted can be a period of time other than since the last reorganization. In step 410, the B-tree optimizer determines whether the total number of pages in the B-tree is greater than a minimum threshold. Although this minimum threshold is a constant that can have any value, in a preferred embodiment of the present invention, the minimum threshold is 5 pages. This value is chosen so that the performance on small B-trees is not impacted by the B-tree optimizer. If the total number of pages is greater than the minimum threshold, then in step 412 the B-tree optimizer determines whether a substantial number of page additions or deletions has occurred since the last reorganization. In the preferred embodiment, a substantial number of page additions or deletions has occurred if the total number of pages is less than a page deletion factor times the number of page deletions plus a page addition factor times the number of page additions. The page deletion and addition factors reflect significant changes to the structure of the B-tree. In the preferred embodiment, the page deletion factor is chosen to be "2" and the page addition factor is chosen to be "1". These factors reflect that page deletions are considered to be more significant than page additions, because page deletions indicate the B-tree is becoming empty. If the total number of pages in the B-tree is greater than the minimum threshold (step 410) and a substantial amount of page additions or deletions has occurred (step 412), then in step 414 the B-tree optimizer determines that the B-tree needs to be reorganized. If either the total number of pages in the B-tree is less than the minimum threshold (step 410) or a substantial amount of page additions or deletions has not occurred (step 412), then the B-tree optimizer conducts a second test to determine whether the B-tree should be reorganized. The second test used in the preferred embodiment depends upon the number of key values that have been deleted from the B-tree since the last reorganization and an amount of time that has passed since the last reorganization. Referring now to Figure 4B, in step 416 the B-tree optimizer determines the number of key values that have been deleted from the B-tree since the last reorganization. This information is preferably obtained from the activity statistics stored in the root node of the B-tree. The B-tree optimizer then determines the average number of key values that have been deleted from each page (number of key value deletions divided by number of pages). In step 418 the B-tree optimizer determines an amount of time that has passed since the last reorganization. The time of the last reorganization is preferably stored with other activity statistics in the root node of the B-tree. In step 420, the B-tree optimizer determines whether the amount of time since the last reorganization is greater than a minimum amount of time. This minimum amount of time can vary greatly, depending upon administration input. If a user of the computer system will be affected by pauses as a result of a reorganization, then the minimum amount of time should be a large number of days. If the amount of time that has passed since the last reorganization is not greater than a minimum amount of time, then the B-tree optimizer determines that the B-tree does not need to be reorganized (step 422). If the minimum amount of time since the last reorganization has passed (step 420), then the B-tree optimizer determines in step 424 whether the average number of key values per page that have been deleted since the last reorganization is greater than a key value deletion threshold. In the preferred embodiment, the key value deletion threshold is chosen to be "5" to represent about 10%-15% of the total page size. If the average number of key values that have been deleted per page since the last reorganization is greater than the key value deletion threshold (i.e., more than 10%-15% of the page is free space), then the B-tree optimizer determines that the B-tree needs to be reorganized (step 426). If the average number of key values that have been deleted per page since the last reorganization is less than the key value deletion threshold, then the B-tree optimizer conducts a third test to determine whether the B-tree should be reorganized. The third test used in the preferred embodiment depends upon the difference between the fill factor at the time of last reorganization and the optimal fill factor, and the amount of time that has passed since the last reorganization. In step 428 the B-tree optimizer determines whether the amount of time that has passed since the last reorganization is greater than a minimum amount of time. In the preferred embodiment, this minimum amount of time is chosen to be a fairly high number (approximately 14-30 days) because the fill factor changes only after activity in the B-tree changes. For example, there may be a fair amount of activity in a B-tree after it is first created, and less later. A 14-30 day time period might reflect such shifts. If the amount of time since the last reorganization is less than the minimum amount of time, then the B-tree optimizer determines that the B-tree does not need to be reorganized (step 430). If the amount of time since the last reorganization is greater than the minimum amount of time, then in step 432 the B-tree optimizer computes the optimal amount the B-tree pages should be filled (i.e., the optimal fill factor). In step 434 the B-tree optimizer determines whether the optimal fill factor is greater than the fill factor at the time of the last reorganization. If it is not, then in step 430 the B-tree optimizer determines that the B-tree should not be reorganized. Otherwise, the B-tree optimizer determines that the B-tree needs to be reorganized (step 436). After the B-tree optimizer determines that the B-tree needs to be reorganized (step 306 in Figure 3), the B-tree optimizer computes an optimal fill factor for pages of the B-tree (step 308 in Figure 3). In a preferred embodiment, the optimal fill factor varies from a minimum fill factor to a maximum fill factor using a linear scale based upon a percentage of pages that were split since the last reorganization. Although many different methods may be used to determine the optimal fill factor, the method used in the preferred embodiment of the present invention is described below with reference to the flow diagram of Figure 5. Beginning with step 502 (Figure 5), the B-tree optimizer determines the total number of pages that have been added to the B-tree since the last reorganization. This information is preferably obtained from the activity statistics stored in the root node of the B-tree. Next, in step 504 the B-tree computes the number of page splits that have occurred since the last reorganization. This number is computed by multiplying the total number of pages in the B-tree by a split factor. In a preferred embodiment, the split factor is chosen to be "2" because for every page added as a result of a split, two pages are half full. Therefore, if half of the pages in the B-tree are split, each page will be half full. The B-tree optimizer then determines in step 506 whether the number of page splits is greater than the total number of pages in the B-tree. If so, then in step 508 the B-tree optimizer sets a variable representing the number of non-split pages to zero. If the number of page splits is less than the total number of pages in the B-tree (step 506) then in step 510 the B-tree optimizer sets the variable representing the number of non-split pages equal to the total number of pages minus the number of page splits. In step 512 the B-tree optimizer computes the optimal fill factor. In a preferred embodiment, the calculation used to compute the optimal fill factor (FF) is as follows: FF = FFmin + (FFmax - FFmin) * number of non-split pages total number of pages The value for the minimum fill factor (FFmin) should be chosen so that it represents the minimum fill factor desired when the B-tree is reorganized. In the worst cast, the B-tree optimizer will generate a fill factor of 50%. A fill factor should be chosen that is above 50%, but not too high so as to overfill a dynamic B-tree. In a preferred embodiment, the minimum fill factor is chosen to be a value between 55%-65%. The value for the maximum fill factor (FFmax) should be slightly less than 100% because it is desirable to leave a small amount of space on each page so that a split does not occur immediately after the next key value is added to the B-tree. In a preferred embodiment, the maximum fill factor is chosen to be between 80%-90%. After computing the optimal fill factor for the B-tree (step 308 of Figure 3), the B-tree optimizer reorganizes the B-tree. Reorganization of the B-tree involves creating a new B-tree and moving all of the key values and pointers contained within the pages of the old B-tree to the new B-tree. In the preferred embodiment, the B-tree optimizer carries out the steps shown in the flow diagram of Figure 6 to reorganize the B-tree. In step 602 the B-tree optimizer computes the amount of storage space needed for the new B-tree. The amount of space needed is computed by scanning the existing B-tree and totaling the sizes of each [key value, pointer] pair in the B-tree. Based upon the optimal fill factor previously computed (step 306 of Figure 3) and the total size of all of the [key value, pointer] pairs in the B-tree, the B-tree optimizer computes the size needed for the new B-tree. In the preferred embodiment, the size of the new B-tree is computed up front to make sure the operation will succeed (i.e., there is enough space for the new tree) and also to make it more likely that the space allocated for the new B-tree will be contiguous on the secondary storage device. After computing the size needed for the new B-tree, in step 604 the B-tree optimizer allocates enough space for the new B-tree. The B-tree optimizer then builds the new B-tree in step 606. The new B-tree is built by scanning the existing B-tree and adding [key value, pointer] pairs to the new B-tree. In the preferred embodiment, the B-tree optimizer maintains a stack of pages representing the different levels of the new B-tree (e.g., the current leaf page, the current first level non-leaf page, the current second level non-leaf page, . . . , the root page). As the B-tree optimizer fills each leaf page in the new B-tree, the B-tree optimizer writes the leaf page to the secondary storage device, and adds a [key value, pointer] pair to the first level non-leaf page. The B-tree optimizer uses a recursive algorithm so that when the non-leaf page fills up, the non-leaf page is written to the secondary storage device and the first key value on the non-leaf page is added to the parent page. In this way, the B-tree is built by writing each leaf and non-leaf page exactly one time. After all [key value, pointer] pairs are written to the new B-tree, the leaf and non-leaf pages that are only partially filled are written to the secondary storage device along with the root page. Those skilled in the art will appreciate that other methods may be used to create the new B-tree.

Claims: A method, for use in a computer system (200), of optimizing storage of a B-tree, the B-tree comprising a plurality of pages, each page having storage capacity for a predetermined amount of data, the method comprising the steps of: gathering and analyzing (302) activity statistics associated with the B-tree; determining (304), based upon the result of the step of analyzing (302), whether the B-tree should be reorganized; and in case that it is determined that the B-tree should be reorganized (304:J): determining (306) from the activity statistics an optimal fill factor for the pages of the plurality of pages, the optimal fill factor indicating an amount of data to be stored on each page relative to the size of a page of the plurality of pages, and reorganizing (308) the B-tree by using the optimal fill factor to determine the amount of data to be stored in each page of the reorganized B-tree. The method as claimed in claim 1 wherein: the step of analyzing activity statistics comprises determining the number of pages in the B-tree; and the step of determining whether the B-tree should be reorganized is further based (432) on the number of pages in the B-tree. The method as claimed in claim 1 or 2 wherein: the step of analyzing activity statistics comprises determining (408) a total number of pages that have been added to the B-tree or deleted from the B-tree during a selected period of time; and the step of determining whether the B-tree should be reorganized is further based (412) on the total number of pages, that have been added to or deleted from the B-tree during the selected period of time. The method as claimed in one of claims 1 to 3 wherein: the step of analyzing activity statistics comprises determining (416) a total number of key values that have been deleted from the B-tree during a selected period of time; and the step of determining whether the B-tree should be reorganized is further based (424) on the total number of key values that have been deleted from the B-tree during the selected period of time. The method as claimed in one of claims 1 to 4 wherein: the step of analyzing activity statistics comprises determining an average amount of data that was stored in each page of the B-tree at a previous time that the B-tree was reorganized; and it is determined that the B-tree should be reorganized when a specified amount of time has passed (418) since the previous time that the B-tree was reorganized and a specified amount of data that should be stored on each page of the B-tree is greater than the average amount of data that was stored on each page of the B-tree at the previous time (432). The method as claimed in one of claims 1 to 5: in case that the step of analyzing activity statistics determines that less than a predefined amount of activity has occurred within the B-tree, classifying the B-tree as static; and in case that the step of analyzing activity determines that more than the predefined amount of activity has occurred within the B-tree, classifying the B-tree as dynamic. The method as claimed in claim 6 wherein the step of determining the optimal fill factor is further based on the classification of the B-tree as static or dynamic, such that the optimal fill factor has a first value in case that the B-tree is classified as static and a second value in case that the B-tree is classified as dynamic. A computer system (200), for optimizing storage of a B-tree, the B-tree comprising a plurality of pages, each page having storage capacity for a predetermined amount of data, the computer system comprising: monitoring means for gathering and analyzing (302) activity statistics associated with the B-tree decision means for determining (304), based upon the result of the analysis of the activity statistics, whether the B-tree should be reorganized; and reorganization means for reorganizing (308) the B-tree in case that it is determined that the B-tree should be reorganized (304:Y), the reorganization means comprising: means for determining (306) from the activity an optimal fill factor for the pages of the plurality of pages, the optimal fill factor indicating an amount of data to be stored on each page relative to the size of a page of the plurality of pages, and means for storing in each page of the reorganised B-tree an amount of data determined by the optimal fill factor. The system as claimed in claim 8 wherein: the monitoring comprises means for determining the number of pages in the B-tree; and the decision means further operates based (432) on the number of pages in the B-tree. The system as claimed in claim 8 or 9 wherein: the monitoring means comprises means for determining (408) a total number of pages that have been added to the B-tree or deleted from the B-tree during a selected period of time; and the decision means further operates based (412) on the total number of pages that have been added to or deleted from the B-tree during the selected period of time. The system as claimed in one of claims 8 to 10 wherein. the monitoring means comprises means for determining (416) a total number of key values that have been deleted from the B-tree during a selected period of time; and the decision means further operates based (424) on the total number of key values that have been deleted from the B-tree during the selected period of time. The system as claimed in one of claims 8 to 11 wherein: the monitoring means comprises means for determining an average amount of data that was stored in each page of the B-tree at a previous time that the B-tree was reorganized; and the decision means determines that the B-tree should be reorganized when a specified amount of time has passed (418) since the previous time that the B-tree was reorganized and a specified amount of data that should be stored on each page of the B-tree is greater than the average amount of data that was stored on each page of the B-tree at the previous time (432). The system as claimed in one of claims 8 to 12, further comprising. means for classifying the B-tree as static in case that the monitoring means determines that less than a predefined amount of activity has occurred within the B-tree; and means for classifying the B-tree as dynamic in case that the monitoring means determines that more than the predefined amount of activity has occurred within the B-tree. The system as claimed in claim 13 wherein the means for determining the optimal fill factor further operates based on the classification of the B-tree as static or dynamic, such that the optimal fill factor has a first value in case that the B-tree is classified as static and a second value in case that the B-tree is classified as dynamic.

Inventors: BERKOWITZ BRIAN THOMAS, BERKOWITZ, BRIAN THOMAS
Applicants: MICROSOFT CORP, MICROSOFT CORPORATION
Application year: 1994
Main classification: G06F17
IPC codes: G06F17, G06F12