Background of the Invention
A data base has been define as a collection of data that can be concurrently shared and used by multiple applications. Data bases have evolved from simple file systems to massive collections of data serving a community of users and numerous distinct applications.
The data disposed within a data base can be organized as a plurality of records. Each record typically includes data values for one or more common categories of information. For example, each of a plurality of records may include information (i.e. data values) for the following categories: a person's name, address, age, gender, telephone number, account numbers and credit limits.
One important data base tool is the data base management system (DBMS). A DBMS is a data processor which aids in the storage, manipulation, reporting, management and control of the data base. Since the 1970's, DBMSs have become widely used and are becoming the main technology for general purpose data base management.
One purpose of a DBMS is to answer decision support queries and support transactions. A query may be defined as a logical expression over the data and the data relationships set forth in the data base, and results in identification of a subset of the data base. For example, a typical query for the above-noted data base might be a request for data values corresponding to all customers having account balances above required limits. A transaction includes several query and altering operations over data and is used to define application events or operations.
A DBMS typically utilizes one or more indexes to answer queries. Indexes are organized structures, created by a data base administrator, associated with the data to speed up access to particular data values (i.e. answer values). Indexes are usually stored in the data base and are accessible to a data base administrator as well as end users.
One indexing approach is based on a structure known as the B-tree. A B-tree index is a multi-level, tree-structured index in which all leaf entries (i.e. data values) in the structure are equidistant from the root of the tree. As a result, the B-tree index provides uniform and predictable performance for retrieval operations. A B-tree index includes a root page, zero or more intermediate pages and a set of leaf pages. The leaf level includes an entry for each unique value of the indexed data, providing the indexed value and an indication (typically a row identifier) for each data base record that contains the value. Each level above the leaf level contains an index entry for every page of the level below. Thus, the B-tree structure provides relatively fast, direct access to the leaf pages and hence, the indexed data.
Another indexing approach, which is a refinement of B-tree indexing, is known as the keyword indexing. In this approach, a modified B-tree is formed for the unique values of a group of data values. More specifically, the B-tree has only the unique values at the leaf level with a bit map associated with each unique value. For example, consider a block of data having fifty thousand records (i.e. distinct rows of data) which indicate, among other things, gender for each of fifty thousand people. In this situation, there are three unique values: male, female and undefined. Thus, three bit maps would be generated, one each for male, female and undefined. Each bit map would have fifty thousand bits, with ONE bits at locations corresponding to those people with that gender and ZERO bits at locations corresponding to those people having another gender.
Existing indexing approaches, such as those described above, are not without problems. For example, the B-tree indexing approach typically requires a substantial period of time for creating the indexes. Once created, existing B-tree indexes occupy a large portion (e.g. 250% of the space allotted for the data) of memory. Additionally, B-tree indexes are not always fast enough for decision support queries on large-scale DBMSs.
Summary of the Invention
The present invention, in general, is directed to an index method and apparatus for creating and maintaining indexes in a more efficient manner than existing indexing approaches. Consequently, indexes can be formed in less time and occupy less space in memory with the present approach than with known indexing approaches, particularly for medium cardinality data (i.e. about one hundred to eighty thousand unique data values) and high cardinality data (i.e. about eighty thousand plus unique data values). As such, decision support queries can be processed faster (i.e., up to one hundred times faster) than in existing index approaches. Further, the present index method and apparatus provide seamless technology that enhances the capabilities of existing DBMSs, particularly when employed with large data base systems (i.e., greater than one million records) and used for decision support queries.
More specifically, the present invention features a server for performing an index method of data management. The server is disposed between a processor running an application program and a DBMS and is coupled to a data base located within the DBMS. The data base has an ordered set of data values stored in memory. The set of data values may, for example, correspond to numbered rows of complete records or numbered rows of a subset (i.e., one or more columns) of the records. Each data value has a bit pattern and a unique identifier (e.g., a row identification number) associated therewith.
In accordance with the present indexing method, the server performs the step of creating a plurality of bit vectors. Preferably, the number of bit vectors created equals the length of the longest bit pattern for the values. Preferably, each bit vector initially has the same value (i.e. ZERO or ONE) in each bit location. The server subsequently performs the step of accessing one of the values stored in the data base. The server then performs the step of assigning each bit of the bit pattern for the value, preferably from the most significant bit to the least significant bit, to a unique position in successive bit vectors. The bits are assigned to identical unique positions in each of the successive bit vectors. For example, for a first value, each bit is assigned to the first bit position for each bit vector. The server repeats the above-described accessing and assigning steps for each remaining value of the set to form an index of bit vectors for the values.
Using the above-described method, a complete set of indexes can be formed that is more compact and efficient than known indexes used by DBMS manufacturers. These highly efficient indexes allow for fast retrieval and/or reconstruction of answer data values in response to queries. Further, using the present method, a user can create indexes customized to the cardinality (i.e. low, medium or high) of the data and/or the types of queries to be performed.
Brief Description of the Drawings
The foregoing summary of the invention, and the various features thereof, as well as the invention itself may be more fully understood from the following detailed description when read together with the accompanying drawings.
FIG. 1 is a block diagram of a data processing system incorporating the indexing approach of the present invention.
FIG. 2 is a flow chart illustrating process steps for forming an index in accordance with the present method.
FIG. 3 is an illustration of a sample data base including multiple columns of data values.
FIG. 4 is a sample index of bit vectors created in accordance with the present method.
FIG. 5 is a flow chart illustrating process steps for retrieving or reconstructing data values in response to a query using the present method.
FIG. 6 is a chart illustrating the results of a sample query performed using the present method.
FIG. 7 is a flow chart illustrating process steps for comparing a search value to data values assigned into an index.
Detailed Description of the Invention
The present invention features an indexing method and apparatus for creating and maintaining indexes for data in a more efficient manner than existing indexing approaches. Indexes can be formed in less time and occupy less space in memory with the present approach than with known indexing approaches, particularly for medium and high cardinality data. As such, decision support queries can be processed up to one hundred times faster than in existing index approaches.
Referring to FIG. 1, the present invention features a server 10 for creating an index for data management within the data processing system 12. The server 10, which may be simply a set of software instructions stored on a disk or in memory, comprises a processor 14 and a memory 16 for storing each index created by the processor. Preferably, the server 10 is disposed between a processor 10 running an application program 18 and a data base management system (DBMS) 20. The processor 18 includes the hardware and software necessary to provide a user interface to the DBMS 20. The DBMS, which may be any backend data base (e.g., Sybase or Oracle), includes a data base 22 to which the server 10 is coupled.
Referring to FIG. 2, the data base 22 can include an ordered set of data values stored in the memory 24. The set of data values may correspond to numbered rows 26 of complete records or of one or more columns 28 of the records. Each data value 30 has a bit pattern and a unique identifier 32 (i.e., a row identification number) associated therewith. In this example, all of the data values 30 in a given column 28 have bit patterns of the same length. In general, the data values need not have the same length.
Referring to FIG. 3, the server 10 performs the processing steps for creating an index of bit vectors (see FIG. 4). As shown, the processing steps include: creating a plurality of bit vectors such that the number of bit vectors created equals the length of the longest bit pattern for the values (step 32); accessing one of the values stored in the data base (step 34); assigning each bit of the bit pattern for that value, from the most significant bit to the least significant bit, to a unique position in successive bit vectors (step 36); repeating the above-described accessing and assigning steps for each remaining value of the set to form an index of bit vectors for the values (steps 38,40); and optionally discarding the ordered set of values stored in the data base (steps 42).
Referring to FIG. 4, the present method can be employed to create an index for the left-hand column of data values (i.e. the numbers) shown in FIG. 2. Accordingly, the server 10 first creates a plurality of bit vectors 44a-44d. The number of bit vectors created equals the length of the bit patterns for the values (i.e. the numbers). For example, if the memory allocates 32 bits per character (or digit) for each value, then 32 bit vectors are created. Preferably, each bit vector initially has all ZEROES in each bit location.
The server then performs the step of accessing the first value (i.e. the number 3) stored in the memory 24. Each value in the memory 24 is represented, in this example, by a 32-bit bit pattern. Thus, the number 3 has a bit pattern 0 . . . 011. Next, each bit of the bit pattern from the most significant bit to the least significant bit is assigned by the server to the first position in each of the bit vectors 44a-44d. In other words, the most significant bit for the number 3 is assigned to the first position of the first vector 44d and the least significant bit is assigned to the first position of the last bit vector 44a.
The server determines whether any unaccessed values remain in the memory 24. Since four numbers remain, the above-described accessing and assigning steps are repeated for each remaining number to form an index 46 of bit vectors for the numbers. The server may also perform a data compression step for reducing the data stored in the data base. To that end, the server may discard or erase the column of numbers or the entire contents of the memory 24 subsequent to the formation of a complete set of indexes.
Using the present method, the server can form a complete set of indexes that are more compact and efficient than known indexes used by DBMS manufacturers, programmers and users. These highly efficient indexes enable the server to quickly retrieve and/or reconstruct answer data values in response to queries.
To that end, the present method can also include additional processing steps enabling fast response/retrieval to one or more decision support queries. Referring to FIG. 5, the server may be equipped to perform the following processing steps: receiving from the application program a query, including a search value and a search function (e.g., <, >, =, etc.), from the application program (step 48); performing, in response to the query, a comparison of the search value to each bit vector in the designated index (step 50); and producing a resultant bit vector having a bit pattern which indicates the unique identifier of each value satisfying the search function (step 52). The server can utilize the resultant bit vector to perform the step of retrieving from the data base each data value satisfying the search function (step 54). Alternatively, the server can perform the step of reconstructing from the index each data value satisfying the search function (step 56). Using either approach, the server can then provide the retrieved or reconstructed values to the application program.
With reference to FIGS. 6-7, the method steps of FIG. 5 can be employed in the server to search the index 46 for retrieving and/or reconstructing those data values greater than a search value (i.e. the number 1) as shown in FIG. 6. As shown, the 32-bit bit pattern for the number 1 is 0 . . . 001. The server receives a query from, for example, the application program. The query may be a request for those data values in the index 46 which are greater than the number 1. Responsive to the query, the server compares the number 1 to each of the values assigned into the index. This comparison step is performed by manipulating the bit vectors 44a-44d, including performing Boolean functions on selected bit vectors, based on the search value and the search function.
In this example, the comparison step is performed in accordance with the flow chart shown in FIG. 7. With reference to FIGS. 6 and 7, beginning with the first value (i.e. N=1) and starting from the least significant bit of the search value, ONE bits are skipped (step 57). Thus, the least significant bit of the search value is skipped such that the first position of the answer vector 58 is blank. Next, beginning with the least significant ZERO bit in the search value, the corresponding bit of the first value, located in the corresponding bit vector, is copied into the first position of the second answer vector 60 (step 59). Since the second bit for the number 1 is a ZERO, the second bit (i.e. 1) of the the first value (i.e. 3) of the vector 44b is copied into the first position of the answer vector 60. If the next bit in the search value is a ONE, the next bit of the first value, which is located in the first position of the next bit vector, is ANDed with the bit located in the first position of the answer vector 60; alternatively, if the next bit in the search value is a ZERO, the next bit of the first value is ORed with the bit in the first position of the answer vector 60 (step 61). In this example, the next bit (i.e. the third bit) of the first value is a ZERO, so that ZERO bit is ANDed with ONE bit in the first position of vector 60 and the result is listed in the first position of the answer vector 62. The AND/OR step is subsequently repeated for the first value until all 32 bits have been compared to the bits of the search value (step 63). Next, it is determined whether the vectors include any additional data values (step 63). If they do, the comparison steps (steps 59-63) are repeated for next data value. Once the comparison is performed on all data values, the process is stopped.
After the comparison is complete, the server produces a resultant bit vector 64 having a bit pattern which indicates (via ONEs in appropriate bit positions corresponding to the row identifiers) the numbers satisfying the search function. As shown, the first third and fourth numbers in the memory satisfy the search function (i.e. numbers greater than 1).
The server can utilize the resultant bit vector 64 to retrieve from the memory 24 (FIG. 2) each number satisfying the search. To that end, the server would retrieve the numbers stored in those rows of the first column of the memory indicated in the bit pattern of the resultant vector 64. Alternatively, the server may reconstruct from the index those numbers satisfying the search. The server selects the first bit of each bit vector to reconstruct the number corresponding that which is stored in the first row of the memory 24 (FIG. 2). Similarly, the server selects the third and fourth bits of each bit vector to reconstruct the numbers corresponding those stored in the third and fourth rows of memory. With this approach, the server does not have to access the memory 24 to respond to a query. Using either approach, the server can then provide the retrieved or reconstructed values to the application program.
The speed of searching indexed data can depend on, for example, the cardninality of the data, the complexity of the search query, etc. Accordingly, the present method allows a user to select the type of index to be formed. As such, a user can form a B-tree index or a bit vector index depending upon such factors as the cardinality of the data, the data base size and the query.
While various embodiments of the invention have been set forth in detail, it should be understood that the above description is intended as illustrative rather than limiting and that many variations to the described embodiments will be apparent to those skilled in the art. The invention is to be described, therefore, not by the preceding description, but by the claims that follow.