US 6,353,820 B1Grant
Method and system for using dynamically generated code to perform index record retrieval in certain circumstances in a relational database manager
Issue Date:2002-03-05
•18 Claims
•7 Drawing Sheets
Abstract
A system and method that enhances the index processing performance of a multi-layer relational database manager by expanding the code generation component layer of the database manager to include an index processing performance enhancing subroutine designed to execute functions performed by lower component layers substantially faster than if the functions were executed by such lower component layers. The subroutine includes logic for establishing the conditions under which the particular subroutine is invoked during the execution of a SQL request. The output code generated to execute a specific SQL query, including calls to the index processing subroutine in place of normally included calls to the lower component layer. This enables the generated code to perform lower component layer functions with specialized code designed to increase performance.
Metadata
Assignee
- Bull HN Information Systems Inc.
Inventors
- David S. Edwards
- Todd Kneisel
Application Information
Application Number:US 09/408,986
Filing Date:1999-09-29
Priority Date:1999-09-29
Art Unit:7
Classifications
IPC:
G06F 1730
Field of Search:
707 1707 2707 3707 4707 5707 10707101707102707103 R7071041707206709201709215709216711 4711100711112711150711171711200711202711216711217714 11705 35
Patent Drawings (7 sheets)
Description
RELATED PATENT APPLICATIONS
[0002] 1. A Method and System For Using Dynamically Generated Code to Perform Record Management Layer Functions in a Relational Database Manager invented by David S. Edwards, David A. Egolf and William L. Lawrance, filed on even date, bearing Ser. No. 09/408,985 and assigned to the same assignee as named herein.
[0003] 2. A Method and System For Dynamically Generating Code to Enhance the Performance of a Relational Database Manager That Provides Access to a Relational Database invented by David S. Edwards, David A. Egolf and William L. Lawrance, filed on even date, bearing Ser. No. 09/408,767 and assigned to the same assignee as named herein.
BACKGROUND OF THE INVENTION
[0004] 1. Field of Use
[0005] The present invention relates to data processing systems and more particularly to database management systems.
[0006] 2. Prior Art
[0007] Typically, today's enterprise or legacy systems store large quantities of data in database systems accessed by database management system (DBMS) software. In such database systems, data is logically organized into relations or tables wherein each relation can be viewed as a table where each row is a tuple and each column is a component of the relation designating an attribute. It has become quite common to use relational database management systems (RDMS) for enabling users to enter queries derived from a database query language, such as SQL, into the database in order to obtain or extract requested data.
[0008] In compiling type database management systems, an application program containing database queries is processed for compilation prior to run time. This can be done and more frequently is done at run time by users of the INTEREL product discussed herein. Users of other database products such as DB2, do such processing prior to run time.
[0009] During compilation, database queries are passed to the database management system for compilation by a database management system compiler. The compiler translates the queries contained in the application program into machine language. Generally, a database compiler component referred to, as a query optimizer is included in the database management system to select the manner in which queries will be processed. The reason is because most users do not input queries in formats that suggest the most efficient way for the database management system to address the query. The query optimizer component analyzes how best to conduct the user's query of the database in terms of optimum speed in accessing the requested data. That is, the optimizer typically transforms a user query into an equivalent query that can be computed more efficiently. This operation is performed at compile time, in advance of execution.
[0010] A major component of the RDBMS is the database services component or module that supports the functions of SQL language, such as definition, access control, retrieval and update of user and system data. Such components may utilize a multilayer structure containing submodules or components for carrying out the required functions. For example, one such system includes a series of components or conceptually, a series of layers for carrying out the required functions for accessing data from the relational database. More specifically, a first layer functions as a SQL director component that handles requests at the interface to the requesting or calling application program. A second layer consists of two major components, an optimizer for optimizing the query and a RAM code generation component. The optimizer processes the query by for example, by determining the appropriate access plan strategy. The code generation component (Codgen) generates code according to such plan for accessing and processing the requested data. The access plan defines the type of access to each table, order of access, whether any sorts or joins are performed along with other related information.
[0011] The generated code is passed to a third layer that functions as a relational file manager (RFM) component. This component layer performs the relational file processing function of translating the code-generated requests into IO file read/write requests. A fourth layer that functions as an IO Controller performs the requested I/O operation designated by such IO file requests that results in reading/writing the relational database files in page increments. The described architecture is characteristic of the INTEREL product developed and marketed by Bull HN Information Systems Inc. For information concerning this product, reference may be made to the publication entitled, “Database Products INTEREL Reference Manual INTEREL Performance Guidelines, Copyright, 1996 by Bull HN Information as Systems Inc., Order No. LZ93 Rev01B.
[0012] It was noted that index searches are very common operations in relational databases. They occur when processing SELECT, UPDATE or DELETE statements. Because they occur so frequently, it is an area where performance improvement could result in a substantial benefit for a relational database system such as the above architecture. For example, the above architecture processes the following typical query as follows:
[0013] Select accountID from tableFunds where accountBalance>=50000;
[0014] With DDL:
[0015] create table tableFunds (accountld int, accountBalance numeric(11,0)
[0016] create index i1 on tableFunds (accountBalance);
[0017] After an examination of this query, it is seen that many accounts may qualify. Because the index is on the accountBalance column and index data is sorted order, the query would be processed in the following manner. First, the index entry for 50,000 must be retrieved, then the subsequent index entries (i.e., all for accountBalances of 50,000 or greater) must be retrieved until the index is exhausted.
[0018] The above architecture performs index processing in the following two steps. First, the Codegen component layer calls the RFM component layer to search for a specific index value. This is called a Find Index search which is used to locate the database key (DBK) of a record from an index key value provided by the caller (i.e. user's search request). Once the RFM component layer finds the index entry, it establishes a currency to it. This currency is control information that indicates which fine level index entry corresponds with the search request. This currency information is stored in the RFM component layer's schema structure. The RFM component layer establishes a currency ID for the currency from currency ID information that the code generation component layer sets in an RFM data structure (RFM_XPT) prior to the call.
[0019] In the second step, the Codegen component layer calls the RFM component layer to return the next index entry (i.e., Search Next Index entry). The index fine level entries are in sorted order and because the Codegen layer passes in the currency ID from the prior search, the RFM layer can go to the currency information stored in the schema structure and use it to find the next index entry without repeating the index search. After the RFM layer has identified the next index entry, it updates the currency information in the schema. This second step is repeated until query processing is complete. This process is quite time consuming in terms of the overhead expended in invoking/calling lower component layers to perform index processing.
[0020] Accordingly, it is a primary object of the present invention to provide a more efficient method and system for improving relational index processing.
SUMMARY OF THE INVENTION
[0021] The above objects are achieved in a preferred embodiment of the present invention that can be utilized in a relational database management System (RDMS) that implements the Structured Query Language (SQL) standard. The present invention is a system and method that enhances the index processing performance of a multi-layer relational database manager. According to the teachings of the invention, the code generation component layer of the database manager includes an index processing performance enhancing subroutine designed to execute functions performed by lower component layers substantially faster than if the functions were executed by such lower component layers. The output code generated by the code generation component layer includes calls to the index processing performance enhancing subroutine thereby incorporating such subroutine into the output code.
[0022] The subroutine includes logic for establishing the conditions under which the particular subroutine is invoked during the execution of a SQL request. In the preferred embodiment, the logic detects when there is more than one search next index operation is requested for a particular query. On the second search next index request, the subroutine logic examines a fine level index page (CI) from which the prior index entry was retrieved. This CI was obtained by RFM during the initial B Tree index search and resides in the buffer pool. If there have been no changes in index currency and in the fine level index, then the subroutine copies the fine level index entry to the requestor's key buffer along with a database key value. Also, the currency information is updated to point to the next fine level index entry.
[0023] When the logic detects the presence of above conditions, this eliminates having to make calls to the lower component layers (i.e., RFM and IO component layers), thus bypassing these layers. This results in substantial increase in performance.
[0024] It will be appreciated that not all sequential index searches processed by the output code and that the enhanced index processing subroutine will be able to bypass the lower component layers. That is, it is still necessary to call the layer that performs I/O operations (i.e., IO component layer) while doing a sequential index search if more than one result is required to be processed. This occurs in the case where a result is returned in response to a SELECT statement used in conjunction with a FETCH cursor statement and a subsequent query issues an index search to an identical index in another database (model).
[0025] To protect against any possible page (CI) integrity problem, the IO component layer must be called to refresh the fine level index CI pointer once the first or original search request is resumed. But, even for the case where the IO component layer must be called, performance is still greatly enhanced by bypassing the RFM component layer. According to the present invention, at code generation time, the code generation component layer places into the output code generated for a particular query, the control logic for determining when a result has been processed and for setting a result processed flag indicator. Those types of queries that do not return a result or return only a 1 result will not have the code generated for them that sets the result processed flag. Queries that fall into this category are DELETE, UPDATE and SELECT INTO (e.g. SELECT COUNT(*)).
[0026] The above objects and advantages of the present invention will be better understood from the following description when taken in conjunction with the accompanying drawings.
BRIEF DESCRIPTION OF THE DRAWINGS
[0027] FIG. 1 is an overall block diagram of a data processing system that utilizes the teachings of the present invention.
[0028] FIG. 2 is a block diagram illustrating the multi-layer organization of the relational database manager system (RDMS) of FIG. 1.
[0029] FIG. 3ais a block diagram illustrating in greater detail, the major components of the second layer of the RDMS of FIG. 2a.
[0030] FIG. 3bis a block diagram illustrating in greater detail, the code generation component of FIG. 2 designed to utilize the teachings of the present invention.
[0031] FIG. 3cillustrates the operational relationships between the second and third layers of the RDMS of FIG. 2a.
[0032] FIGS. 4aand 4bare flow diagrams used to describe the operation of the preferred embodiment of the present invention.
DESCRIPTION OF THE PREFERRED EMBODIMENT
[0033] FIG. 1
[0034] FIG. 1 is a block diagram of a conventional data processing system 10 that utilizes the system and method of the present invention. As shown, the system 10 includes a plurality of processing units 12-1 through 12-n which connect to a system bus 14 through their individual physical caches in common with a number of input/output units (IOUs) 16-1 through 16-n and a system control unit (SCU) 22. As shown, each IOU couples to a particular I/O subsystem (i.e., 19-1 through 19-n) which in turn connect to any one of a number of different types of devices both local and remote such as workstation 21-1 via a network 20 or disk mass storage units 21-n as indicated.
[0035] The SCU 22 connects to a number of memory units (MUs) 24-1 through 24-n. For the purpose of the present invention, system 10 may be considered conventional in design and may for example utilize a mainframe computer system such as the DPS9000 manufactured by Bull HN Information Systems Inc. which operates under the control of the GCOS8 operating system.
[0036] As shown, the system 10 further includes disk storage 21-n that contains the database system that utilizes the teachings of the present invention. It will be appreciated that the software components that comprise the database system including the software components of the present invention may be loaded into the system 10 in a conventional manner (e.g. via CDROM, disk, communications link, etc.). The database system includes a multi-layer relational database management system (RDMS) and a relational database containing established data files. The relational database management system processes all user requests for accessing the files contained on disk storage 21-n. Users initiate such requests via the network 20 by executing transaction processing routines or batch decision support programs via their workstation keyboard and/or via other input devices (e.g. mouse). The system 10 upon receiving an SQL query operates to initiate a search of the relational database files to obtain the data requested by the user.
[0037] In system 10, the relational database management system (RDMS) takes the form of the above mentioned INTEREL software which runs under the GCOS8 operating system. As shown, the RDMS contains a SQL Director component layer, a Codegen Executor component layer, a Relational File Manager (RFM) component layer and an IO Random Controller component layer. These component layers are shown in greater detail, in FIG. 2 along with other database related components.
[0038] FIG. 2—Multi-layer RDMS Organization
[0039] FIG. 2 depicts the major components of the RDMS that utilizes the teachings of the present invention. As shown, these components include the four component layers of RDMS 200 (INTEREL software) discussed above. During normal operation, the different software components of RDMS 200 including the components of the present invention are loaded from disk storage 21-n into memory (e.g. MU 24-1) in a conventional manner.
[0040] In greater detail, SQL Director Component layer 202 operatively couples to an SQL adapter 201 that serves as the application's interface to the RDMS 200. The SQL Adapter 201 includes a runtime library that contains runtime routines bound into the application used by an application such as a COBOL-85 program for issuing calls. Each such call results in library sending a query statement to the SQL Director component layer 202.
[0041] The SQL Director component layer 202 handles the interface processing between RDMS 200 and a calling program. Thus, it manages the database connection. Layer 202 contains routines which analyze each query statement for determining if the statement is of a type that accesses relational database files and thus is suitable for code generation and caching. Each process utilizes a “local cache” for such storage. The use of “local caches” is discussed in the above referenced INTEREL Reference manual. Additionally, reference may be made to the copending patent application of Donald P. Levine and David A. Egolf, entitled: A Method and Apparatus for Improving the Performance of a Database Management System Through a Central Cache Mechanism, bearing Ser. No. 08/999,248 filed on Dec. 29, 1997 which is assigned to the same assignee as named herein.
[0042] As indicated, the SQL Director component layer 202 operatively couples to the RAM Codegen Executor Component layer 204. The SQL Director component layer 202 also contains routines that generate calls to a cache manager component to see if the code for that statement can be found in the process's local cache. When code for that statement is not found in the local cache, the SQL Director component layer 202 calls the RAM Codegen Executor Component layer 204 to process and “potentially” execute the query statement.
[0043] The RAM Codegen Executor layer 204 processes the SQL query. If the code has been generated for a particular query, layer 204 executes such code. When code has not been generated for a particular query, layer 204 optimizes the SQL query, generates code according to the optimized access plan and processes the requested data. The generated output code for the particular query is stored in “local cache” and executed.
[0044] As shown, the RAM Codegen Executor Component layer 204 operatively couples to the Relational File Manager component layer 206. During execution, the generated code calls various RFM functions to read or write relational data and/or index information from RFM files. Hence, this layer does not deal with the physical storage of data in a file.
[0045] The RFM component layer 206 performs the relational processing for RDMS 200. It receives the read and write requests from layer 204 and then translates them into IO file read and write requests respectively. It processes the file pages (CIs) read by layer 208 to which it operatively couples. Thus, this layer hides the physical storage of data and all other file format details from layer 204.
[0046] The IO Random Controller component layer 208 receives the requests from layer 206 and performs the relational file processing of translating the code-generated requests into I/O read/write requests. It processes the database files in page increments (CI). It is oblivious to physical storage of the data on the page. These details are handled by the other components illustrated in FIG. 2a.That is, layer 208 operatively couples to Buffer pools 212 via an Integrity Control Buffer Manager component 210. As known in the art, buffer pools contain buffers having a specific page size (control interval (CI). These buffers are used by the RDMS files. This arrangement is discussed in the above-mentioned INTEREL reference manual.
[0047] RAM Codegen Executor Layer 204—FIG. 3a
[0048] This figure illustrates in greater detail, specific components utilized according to the teachings of the present invention. As indicated, the layer 204 includes a common RAM Optimizer component 204-2, a code generation component 204-4, an SQL cache memory component 204-6 for storing SQL cache routines and generated code and subroutine library component 204-8. These components are operatively coupled as shown.
[0049] As discussed above, optimizer component 204-2 processes the SQL query by determining the appropriate access plan strategy. As a result of such processing, component 204-2 generates a set of EDOT structures that define the operation (SQL query) to execute (e.g. SELECT, UPDATE, INSERT or DELETE), the data to process (e.g. columns), the access method to use (e.g. scan or index or hash) and the restrictions that apply versus the access method to limit the amount of data (or rows) to process. Also, the structures define where the data obtained for the query is to be returned to a user. The path to ODI is used only during EDOT generation for verifying the query for correctness (e.g. does a specified column belong to a specified table). As indicated, the EDOT structures are applied as inputs to Code generation component 204-4. This component generates the required code that is stored in cache storage 204-6.
[0050] The cache storage 204-6 operatively couples to a subroutine library 204-8. Library 204-8 contains subroutines for communicating with RFM component layer 206 that operatively couples to buffer manager 210. In accordance with the teachings of the present invention, library 204-8 also includes an index processing enhancing subroutine that allows the bypassing of the RFM component layer 206 and IO component layer 208 as discussed herein. In this case, library 204-8 operatively couples to IO component layer 208 as indicated in FIG. 3a.
[0051] As indicated in FIG. 3a,the RFM component layer 206 includes several different types of record and index functions. The index functions include a Search Index function and a Search Next Index function. The Search Index function is used to locate the database key (DBK) of a record from an index key value provided by a caller in response to a user's search request. When the key value in the index satisfying the request contains pointers to multiple records (i.e., a duplicated key), the low DBK in the duplicate list will be returned along with a duplicate count. The caller may request one of the following three types of searches against the provided key value: equal, equal/greater than, or equal/less than. Optionally, this function will call an RFM record function (i.e., RFM retrieve record function) on the caller's behalf to return the record containing the index key value.
[0052] The Search Next Index function is used to return next key information to the calling program based upon a currency that has been previously established for the index against which this call is issued. When the current index key value is duplicated, DBKs will be returned from the duplicate list until the list is exhausted. Initial index currency can be established by the search index, store key, delete key and modify key functions. Optionally, this function also will call the RFM retrieve record function on the caller's behalf to return the record associated with the index key value.
[0053] Code Generation Component 204-4—FIG. 3b
[0054] FIG. 3billustrates in greater detail, the structure of a portion of component 204-4 according to the present invention. More specifically, FIG. 3bdepicts the routines that generate the code to perform index or data file retrievals. These routines include a number of standard routines that correspond to blocks 204-40 through 204-49 and 204-53. Additionally, the routines gen_retr_method function 204-50 and gen_index leaf have been extended. The subroutine gen_retr_method 204-50 generates the code to call the high speed row retrieval subroutine for enhancing data row retrieval performance. This subroutine is described in greater detail, in the second referenced copending patent application. The subroutine 204-50 incorporates into the code, any information that is necessary for carrying out the functions of the bypassed RFM manager component 206.
[0055] According to the teachings of the present invention, the subroutine gen_index_leaf 204-54 produces output code that calls the index performance enhancing routine for executing indexing operations under conditions defined by such routine. Appendix IV illustrates this structure in greater detail in generating code for a cursor open (SELECT) command.
Description of Operation
[0056] With reference to FIGS. 1 through 3b,the operation of the preferred embodiment of the present invention will now be described with reference to FIGS. 3c,4aand 4b.
[0057] FIG. 3c
[0058] FIG. 3cillustrates conceptually, the layered organization of the present invention and more particularly, the organization of the code generation component layer 204 when having processed a particular SQL query. For example, FIG. 3cillustrates the case where layer 204 includes the index performance enhancing subroutine corresponding to subroutine IP prestored in subroutine library 204-8 for implementing certain types of index functions. Also, as indicated in FIG. 3c,library 204-8 further includes the normal RFM interface subroutine for carrying out index functions in a conventional manner by use of the lower RFM component layer 206 routines/procedures stored in RFM library 206-8 and IO component layer 208.
[0059] During the processing of an SQL query, the code generation component layer 204 operates to generate output code that includes specific call functions to the index performance enhancing subroutine IP or to the standard RFM interface subroutine. This is indicated in FIG. 3cby the pairs of dotted lines labeled “bypass” and “no bypass” between the output code block and subroutine library 204-8. When a specific operation within a query statement is determined to utilize the index performance enhancing subroutine stored in library 204-8, code generation component layer 204 includes in the output code, a call that references that performance enhancing subroutine thereby bypassing one or more lower component layers.
[0060] As indicated in FIG. 3c,the generated output code contains reference calls to subroutine IP for those parts of the SQL query that involves index searching. As discussed above, index searches can occur when processing SELECT, UPDATE or DELETE SQL statements.
[0061] FIG. 4aillustrates the prior art manner in which index searches are performed. As indicated, the RFM component layer 206 performs a number of tasks when retrieving an index entry. More specifically, first, the RFM component 206 in the case of an index search or first fetch operation processes a B tree index to locate the fine level index page (CI). Such B tree indexes are created with the RFM component via the standard file open function with index attributes defined. The index fine level entries on such page are in sorted order as discussed herein.
[0062] As well known in the art, B tree structures are used by DBMS to allow users to perform queries on large databases or tables using appropriate commands, such as SQL commands. A B tree is an index residing in the database memory having one or more columns, with each column representing another dimension in the index. B trees permit searching for records in a database using one or more keys specified by users via appropriate query commands. Because the keys define a subset of an entire table or records, indexed searching can eliminate the need to search through the entire table of records in order to retrieve a much smaller subset of such records pertinent to the user query.
[0063] The present invention takes advantage of the physical layout of the fine level index entries within a fine level page (CI). The index entries are lightly packed, adjacent to one another in sorted order as indicated. Thus, if one knows the offset to a particular fine level index entry (i.e., the reference entry), its adjacent entry is found by incrementing the pointer to the reference entry by the sum of the size of the reference entry plus the DBKEY size. Therefore, when RFM component layer 206 is called to execute the First Search Next operation, it returns a pointer to the reference entry to the enhancing index subroutine I and the subroutine's index logic uses that pointer to “walk through” the fine level index CI taking entries right out from under the control of the RFM component layer 206 as the Search Next requests are made.
[0064] During operation, the RFM component layer 206 initializes the currency structure to indicate which index entry the currency processing has started with. If the RFM component layer 206 is performing a Search Next operation, it finds the currency structure in the RFM schema structure. The RFM schema structure stores information about all of the aspects of the database tables to be accessed that must remain unchanged for the execution of the execution plan strategy as well as table and file identification (i.e., names of the tables and files) that can change without making the plan strategy inoperable.
[0065] In the case of the Search Next operation, RFM component 206 checks the currency structure's status to determine whether the currency has been invalidated by an UPDATE, INSERT or DELETE operation and if it has, then it returns an error to the requestor. When valid, the RFM component 206 uses the currency structure to determine the index key value to return. It uses this information to identify the page (CI) to make a request to the IO component layer 208. When all the index keys on the fine level CI have been processed by the RFM component 206, it processes the B tree index to determine what CI holds the next fine level key page. If the index entry specifies that it is one of many (duplicate keys), then the duplicate key processing functions of the RFM component layer 206 are invoked.
[0066] After the index entry has been chosen, the RFM component 206 updates the currency structure to indicate that the next entry was taken. Finally, the RFM component 206 copies the index entry into the user's buffer and returns.
[0067] FIG. 4b—Invention Index Processing Flow
[0068] FIG. 4billustrates the enhanced index processing and more specifically, the manner in which index scan operations are executed according to the teachings of the present invention. As indicated in FIG. 4b,the standard index processing is performed by the code generation layer 204 in conjunction with RFM layer 206 in the manner described.
[0069] As indicated in FIG. 4b,the search process is altered to improve index access Search Next performance. The output code calls the index enhancing performance subroutine IP to determine if more than two next index accesses have been processed. On the second Search Next request, the subroutine IP examines the fine level index CI from which the prior index entry was retrieved. If the currency has not changed and the index CI has not changed and if the currency points to a fine level index entry that does not have duplicates, then the subroutine IP copies the requestor's key buffer along with the database key (DBKEY). The subroutine IP updates the currency information to point to the next fine level index entry. Finally, the subroutine IP returns to the caller.
[0070] In greater detail, the key aspect of the present invention is for the code generation component layer 204 to have the RFM component layer 206 fetch the first entry as normal so that the fine level index CI is read into the buffer pool and all the currency information will be established. On the first Search Next call, RFM component layer 206 will return a pointer to the index CI and the currency control structure. For the subsequent Search Next calls, the code generation component layer 204 will use the returned pointer and the currency information to obtain the next key.
[0071] As indicated in FIG. 4b,if the code generation component layer 204 processes a result following an index access, it calls the IO component layer 208 to refresh the index fine level CI pointer. From the DBKEY stored in the currency control information (idx_tb1 structure), code generation component layer 204 determines the CI that is required. The code generation component layer 204 will update the currency information each time it retrieves from the CI, a key that is not a duplicate. The code generation component layer 204 always tests the currency status. When the currency is obliterated or the CI changes, code generation component layer 204 calls the RFM component layer 206 to handle the request and setup the error status.
[0072] When the end of a fine level CI is met, the code generation component layer 204 calls the RFM component layer 206 to do the next Search Next operation so that RFM component layer 206 handles the B tree search for the next CI. When a duplicate is found, the code generation component layer 204 calls the RFM component layer 206 to do the Search Next operation and handle the duplicate processing.
[0073] For a more complete understanding of the benefits of the present invention, the following example of a query and its DDL will now be considered:
[0074] select firstName, ssNumber from student where lastName=‘Jones’ and middleinitial=‘A’; (and this select is associated with a CURSOR, hence many results may be obtained)
[0075] create table student
[0076] (lastName char(20), firstName char(20), middleinitial char(1), ssNumber numeric(12));
[0077] create index ixStudent on student (lastName, firstName, middleinitial;
[0078] And assume that the table includes the following data:
| lastName | firstName | middleInitial | ssNumber | |
|---|---|---|---|---|
| James | Richard | H | 512-66-1234 | |
| Jones | Anne | W | 512-55-1324 | |
| Jones | Don | H | 512-44-1432 | |
| Jones | Joseph | A | 512-33-2134 | |
| Jones | William | E | 512-22-5566 | |
| Justice | Don | T | 512-114144 | |
[0079] The index would be a subset of this data, in sorted order (the six rows in this example are sorted).
[0080] The processing of the above data involves the following steps:
[0081] The RAM Optimizer 204-2 of FIG. 3aprocesses the query at execution time. The Optimizer 204-2 determines that index access via index ixStudent will provide the most efficient access to the data and generates the set of EDOT structures to define the access method, the operation and the columns to be returned. The type of structures generated are illustrated in an appendix.
[0082] Next, code generation component layer 204 is called to generate output code to process the query in accordance with the set of EDOT structures specified by the RAM Optimizer 204-2. Its tasks include the generation of output code to call its subroutine library functions RFM_GET_INDEXE and RFM_IO8_GETNEXT illustrated in FIG. 3cas well as generating output code to evaluate the index entries returned by these functions. The type of output code generated is illustrated in an appendix.
[0083] Next, the generated output code is executed. The output code begins index access with a call to its subroutine library function RFM_GET_INDEXE to find the first index entry beginning with ‘Jones’. This function calls RFM component layer 206 that will search the B tree index until ‘Jones’ is found. This could involve repeated IO component layer calls as the index tree is analyzed to support the search for the fine level index CI that contains the first instance of ‘Jones’.
[0084] Once the fine level index entry for ‘Jones’ is found, the RFM component layer 206 returns the index to the generated output code's key buffer for further analysis by the output code. Next, RFM component layer 206 returns to the subroutine library 204-8 function that will return to the generated output code. The generated output code next verifies that ‘Jones’ was returned and then tests for ‘A’ in the middle initial column of the index entry. Because the first instance of ‘Jones’ does not have ‘A’ as a middle initial, the search continues (assuming that another ‘Jones’ exists).
[0085] Next, the generated output code calls its subroutine function RFM_IO8_GETNEXT to retrieve the next index entry for ‘Jones’. Since the subroutine function RFM_IO8_GETNEXT does not have a pointer to the RFM currency information that is required to “pickpocket” the fine level index CI, it calls the RFM's Search Next function. This function retrieves its currency information and calls the IO component layer 208 for a pointer to the fine level index CI. If the requested CI is in a buffer, IO component layer 208 returns the pointer to the RFM component layer 206. If it is not in a buffer, then IO component layer 208 calls buffer manager 210 of FIG. 2.
[0086] The IO component layer 208 returns with a pointer to the fine level index CI that has been read into the buffer pool. RFM component layer 206 finds the next entry and sets up its currency information. It returns to the subroutine function RFM_IO8_GETNEXT with a pointer to the CI and a pointer to its currency information. The function RFM_IO8_GETNEXT then returns to the generated output code that analyzes the returned index key value. Because the second instance of ‘Jones’ does not have ‘A’ as a middle initial, the search continues. The generated output code again calls the subroutine function RFM_IO8_GETNEXT to retrieve the next index entry for ‘Jones’. Subroutine RFM_IO8_GETNEXT notes that it has all the necessary pointers to find the next fine level index entry in the index CI. Because the prior search did not produce a result, the generated output code did not set the result processed indicator. Therefore, the function RFM_IO8_GETNEXT uses its CI pointer and the RFM currency information to copy the next fine level index entry from the buffer pool to the generated output code key buffer.
[0087] The RFM_IO8_GETNEXT subroutine function increments the RFM currency information, setting it to identify the next index entry to be processed. Then, the RFM_IO8_GETNEXT subroutine returns to the generated output code which analyzes the returned index key value. Because the second instance of ‘Jones’ does have ‘A’ as a middle initial, the output code performs a data file fetch sequence to retrieve the index's associated data file using the DBKEY associated with the index as its row identifier. Because this is an acquisition of a result, the output code sets the result processed indicator which means that the next index search will require a call to the IO component layer 208 at a minimum to refresh its pointer to the fine level index CI.
[0088] After the result is returned to the caller, the caller might request another FETCH from the open cursor and hence call to see if a second ‘Jones’ entry with middle initial ‘A’ exists. If so, the output code calls the subroutine RFM_IO8_GETNEXT. The RFM_IO8_GETNEXT subroutine will note that all the information required to “pickpocket” exists but the results processed indicator is set. Therefore, the subroutine will find the DBKEY for the last fine level index CI fetched from the currency information structure and from this calculate the CI to request from the IO component layer 208. The IO component layer 208 is called to locate the CI. Once identified, the IO component layer 208 will return with a pointer to the CI.
[0089] The RFM_IO8_GETNEXT subroutine uses the CI pointer and the RFM currency information to retrieve the next fine level index entry and copy it to the generated output code key buffer. The RFM_IO8_GETNEXT subroutine then increments the RFM currency information, setting it to identify the next index entry to be processed. The RFM_IO8_GETNEXT subroutine then returns to the generated output code which analyzes the returned index key value. Because the fourth instance of ‘Jones’ does not have an ‘A’ middle initial, the search continues.
[0090] The generated output code again calls the RFM_IO8_GETNEXT subroutine to retrieve the next index entry for ‘Jones’. The subroutine function RFM—IO8_GETNEXT notes that it has all the necessary pointers to find the next fine level index entry in the index CI. Because the prior search did not produce a result, the generated output code does not set the result processed indicator. Therefore, subroutine RFM_IO8_GETNEXT uses its CI pointer and the REM currency information to retrieve the next fine level index entry and copy it to the generated output code key buffer. Again, the RFM_IO8_GETNEXT subroutine increments the RFM currency information, setting it to identify the next index entry to be processed.
[0091] The RFM_IO8_GETNEXT subroutine then returns to the generated output code which analyzes the return index key value. Because the lastName returned is greater than ‘Jones’, the generated output code returns the end of set status and processing is complete.
[0092] The above example illustrates how the present invention bypasses the RFM and IO component layers resulting in a significant reduction in index search time. The Appendices illustrate examples of output code utilized in the preferred embodiment of the present invention. For example, snippets of the specific code used in generating the call to the index enhancing subroutine are included in the appendices.
[0093] While the present invention was described relative to processing SQL statements, it will be obvious to those skilled in the art that the present invention may be used in conjunction with any database oriented systems that seeks to make significant performance gains. This could include all database types including relational database systems as well as “home brew” flat file databases that are used by many application developers. Also, while the preferred embodiment of the present invention operates to invoke the enhanced index processing of the present invention on the second search next index operation, it will be appreciated that as a matter of design choice such processing could occur on the first search next index operation. In the preferred embodiment, it was found that it was simpler to modify the RFM search next logic to capture the required pointers rather than to modify the RFM search index logic to capture the required pointers.
Appendicies
[0094] I. Glossary
[0095] II. Example EDOT output
[0096] III. Structure Chart for Code Generation Component Layer Functionality that Generates Code for a Cursor Open (SELECT) Operation
[0097] IV. Example of Generated Output Code to Call the Index Processing Subroutine I
[0098] V. Code Snippets utilized by the Code Generation Component for Generating the Call to Retrieve the Next Index Entry
[0099] VI. Significant Code from the rfm_io8_getNext Subroutine
| APPENDIX I |
|---|
| Glossary |
| APPENDIX II |
|---|
| 1. Optimizer Output-EDOT Example: |
| TC <- - - - - - - - - - - - - - - - - - - - - - - - - | 145322006112 |
| APPENDIX III |
|---|
| 1. Structure Chart for Code Generation Component Layer Functionality |
| that Generates Code for Cursor Open (SELECT) Operation |
[0100] note 1: If method.control points to a node, gen_index_node is called. Otherwise it must point to a leaf in which case gen_index_leaf is called.
[0101] note 2: The gen_rfm _getni routine is called when a range of values is being retrieved (e.g., WHERE lastName BETWEEN ‘Jones’ AND ‘Lemke’) or when an equal restriction is applied against a non-unique index (e.g., WHERE lastName=‘Jones’).
[0102] note 3: gen_rfm_getni generates a call to the subroutine library function rfm_io8_getNext if the bypassRFM configuration option is set on (the default state). Otherwise, if off, it generates a call to the routine that was used previously, rfm_getnext_index.
[0103] note 4: When afhgrfrn.c option bypassRFM is enabled (default) the new code that generates the call to the library subroutine rfm_io8_getrecord is made. (This does not show the “old” path).
| APPENDIX IV |
|---|
| 1. Example of Code Generated to Call the Index Retrieval Subroutine |
Appendix V
[0104] 1. Code Snippets Utilized by Gen_index_leaf Function for Generating the Call to Retrieve the Next Index Entry
[0105] Snippet 1— gen_index_leaf
[0106] The following code sets the transfer offset based on the state of the bypassRFM option then builds the call to the subroutine library.
[0107] if (bypassRFM)
[0108] calofs=ptr_to_long((void *) rfm_io8_getNext);
[0109] else
[0110] calofs=ptr_to_long((void *) rfm_getnext_indexe);
[0111] calofs &=0077777000000;
[0112] . . .
[0113] if((sts=putcode(calofs | 0300000710100, RELOC_NONE)) <0)
[0114] return (sts); /* TRA getix,,p3 */
| APPENDIX VI |
|---|
| 1. Significant Code from the frm_io8_getNext Subrouting I |
| code snippet 1 - index state tests. |
| if rfm_xpt.r.key_data_prt is NULL then Search Next has not been called. |
[0115] While in accordance with the provisions and statutes there has been illustrated and described the best form of the invention, certain changes may be made without departing from the spirit of the invention as set forth in the appended claims and that in some cases, certain features of the invention may be used to advantage without a corresponding use of other features.
Claims
What is claimed is:
1. A method for enhancing the performance of a data manager that manages a relational database, the manager having a number of operatively coupled component layers for performing functions required for accessing the relational database file records in response to user query statements, the number of component layers including a first component layer for generating output code used in executing the query statement in response to input representing an optimized form of the query statement and a number of lower component layers, the method comprising the steps of:
(a) adding an index processing performance enhancing subroutine to a subroutine library included within the first component layer, the index processing performance enhancing subroutine being designed to execute index processing functions performed by lower component layers substantially faster than if the function were executed by the lower component layers, and including code for determining conditions under which the particular subroutine is to be invoked during query execution time;
(b) including calls in the generated output code to the index processing enhancing subroutine in place of normally included calls to the lower component layers for inserting the index processing enhancing subroutine into the generated code; and,
(c) including logic within the index processing enhancing subroutine for determining if the index processing enhancing subroutine can be reliably invoked based on a predetermined set of conditions.
2. The method of claim 1 wherein the calls included in the generated output code are in place of normally included calls to a prior index processing subroutine that unconditionally invoked lower component layers.
3. The method of claim 1 wherein the predetermined set of conditions indicate that there were no changes in index currency and in a fine level index used for retrieving the database file records.
4. The method of claim 3 wherein the fine level index contains entries that are lightly packed adjacent to one another in sorted order enabling the logic in the index processing enhancing subroutine to walk through the fine level index taking entries right out from under control of one of the number of lower component layers as search next requests are being processed.
5. The method of claim 4 wherein the first component layer includes a code generation component and the one of the lower component layers includes a relational file manager (RFM) component having a library for storing a number of routines for performing the lower layer index functions.
6. The method of claim 5 wherein the number of lower component layers further includes a third lower component layer operatively coupled to the first component layer, to the second lower component layer and to the relational database for executing input/output operations required for executing the query statement.
7. The method of claim 6 wherein in step (c), the first component layer invokes the index processing performance subroutine to call conditionally, the third lower component layer function based on the setting of a result processing indicator.
8. The method of claim 7 wherein the third lower component layer includes an input/output controller component that operatively couples to the relational database.
9. The method of claim 1 wherein the index processing enhancing subroutine is coded for performing a number of different index state tests for determining the set of predetermined conditions.
10. A data manager for managing a relational database, the manager having a number of operatively coupled component layers for performing functions required for accessing database file records of the relational database in response to user query statements, the number of component layers including a first component layer for generating output code used in executing the query statement in response to input representing an optimized form of the query statement and a number of lower component layers operatively coupled to the first component layer, to each other and to the relational database, the lower component layers, the first component layer further including:
(a) a subroutine library including an index processing performance enhancing subroutine designed to execute functions performed by lower component layers substantially faster than if the functions were executed by the lower component layers, the index processing subroutine including coded logic for determining conditions under which the subroutine is to be executed;
(b) the generated output code being stored in memory and including calls to the index processing subroutine stored in the subroutine library in place of normally included calls to a prior index processing subroutine that unconditionally invoked lower component layers; and,
(c) the generated output code when accessed from memory during execution of the query invoking the index processing subroutine to perform the lower layer functions.
11. The data manager of claim 10 wherein the particular conditions indicate there were no changes in index currency and in a fine level index used in retrieving the database file records.
12. The data manager of claim 11 wherein the fine level index contains entries that are lightly packed adjacent to one another in sorted order enabling the coded logic to walk through the fine coded level index taking entries out from under control of the second lower component layer.
13. The data manager of claim 12 wherein the first component layer includes a code generation component and the second lower component layer includes a relational file manager (RFM) component having a library for storing a number of routines for performing the index processing functions utilizing the fine level index.
14. The data manager of claim 13 wherein the number of lower component layers further includes a third lower component layer operatively coupled to the first component layer, to the second lower component layer and to the relational database for executing input/output operations required for executing the query statement.
15. The data manager of claim 14 wherein in the first component layer during the execution of the query invokes the index processing subroutine to invoke the third lower component layer function when a result processing indicator has been set.
16. The data manager of claim 15 wherein the third lower component layer includes an input/output controller component that operatively couples to the relational database.
17. An RDMS program product including a data manager for managing a relational database stored on a media as groups of program instructions, the instructions corresponding to a number of operatively coupled component layers for performing functions required for accessing database file records of the relational database in response to user query statements, the number of component layers including a first component layer for generating code used in executing the query statement in response to input representing an optimized form of the query statement and a number of lower component layers operatively coupled to the first component layer, to each other and to the relational database, the first component layer further including:
(a) a first group of instructions corresponding to a subroutine library that includes an index processing performance enhancing subroutine designed to execute functions performed by lower component layers substantially faster than if the functions were executed by the number of lower component layers, the index processing performance enhancing subroutine including code containing instructions for determining conditions under which the particular subroutine is to be executed;
(b) a second group of instructions corresponding to a code generation component for providing output code containing calls to the index processing performance enhancing subroutine in place of normally included calls to lower component layers that inserts the index processing subroutine into the output code; and,
(c) another group of instructions included within the index processing subroutine for causing the execution of the index processing subroutine to perform the second lower layer functions based on a particular set of conditions resulting in increased performance.
18. A memory for storing a data manager for accessing data records of a relational database during the execution of a query, the memory comprising:
(a) first component layer for generating code used in executing the query statement in response to input representing an optimized form of the query statement and a number of lower component layers operatively coupled to the first component layer, to each other and to the relational database, the lower component layers, the first component layer contained in the memory further including:
(1) a subroutine library including an index processing performance enhancing subroutine designed to execute functions performed by lower component layers substantially faster than if the functions were executed by the lower component layers, the row retrieval performance enhancing subroutine including code for determining conditions under which the particular subroutine is to be invoked during index processing;
(2) generated output code including calls to the index processing performance enhancing subroutine in place of normally included calls to the lower component layers for incorporating the index processing subroutine into the generated output code for execution of the query being processed; and,
(3) a memory area being assigned for storing the output code, the output code accessed during execution of the query causing the index processing subroutine to be executed for performing the lower layer functions as a function of a particular set of conditions so as to result in increased performance.
Patent Citations (24)
| Patent | Date | Inventor | Cited By |
|---|---|---|---|
| US5283894(A) | 1994-02-01 | Deran | Examiner |
| US5408652(A) | 1995-04-01 | Hayashi et al. | Examiner |
| US5544355(A) | 1996-08-01 | Chaudhuri et al. | Examiner |
| US5555388(A) | 1996-09-01 | Shaughnessy | Examiner |
| US5659727(A) | 1997-08-01 | Velissaropoulos et al. | Examiner |
| US5706495(A) | 1998-01-01 | Chadha et al. | Examiner |
| US5717919(A) | 1998-02-01 | Kodavalla et al. | Examiner |
| US5724569(A) | 1998-03-01 | Andres | Examiner |
| US5794228(A) | 1998-08-01 | French et al. | Examiner |
| US5794229(A) | 1998-08-01 | Fench et al. | Examiner |
| US5812996(A) | 1998-09-01 | Rubin et al. | Examiner |
| US5822749(A) | 1998-10-01 | Agarwal | Examiner |
| US5873099(A) | 1999-02-01 | Hogan et al. | Examiner |
| US5918225(A) | 1999-06-01 | White et al. | Examiner |
| US5956706(A) | 1999-09-01 | Carey et al. | Examiner |
| US6073129(A) | 2000-06-01 | Lavine et al. | Examiner |
| US6115703(A) | 2000-09-01 | Bireley et al. | Examiner |
| US6175835(B1) | 2001-01-01 | Shadmon | Examiner |
| US6192370(B1) | 2001-02-01 | Primsch | Examiner |
| US6202070(B1) | 2001-03-01 | Nguyen et al. | Examiner |
| US6233569(B1) | 2001-05-01 | Lehitinen | Examiner |
| US6240422(B1) | 2001-05-01 | Atkins et al. | Examiner |
| US6240428(B1) | 2001-05-01 | Yeung et al. | Examiner |
| US6289334(B1) | 2001-09-01 | Reiner et al. | Examiner |
Non-Patent Literature (3)
- Database Products INTEREL Reference Manual INTEREL Performance Guidelines GCOS 8, Copyright Bull HN Information Systems Inc. 1996, Order No. LZ93 REV01B.Applicant
- Choy, David et al., “A Distributed Catalog for Heterogeneous Distributed Database Resurces”, Proceedings of the First International Conference on Parallel and Distributed Information Systems, Dec. 4-6, 1991, IEEE, pp. 236-244.Applicant
- More, Sachin et al., “Extended Collective I/O for Efficient Retrievel of Large Objects”, HIPC '98, 5th International Conference on High Performance Computing, Dec. 17-20, 1998, pp. 359-366.Examiner