# Patent

## Title
Optimized database appliance

## Abstract

A system from processing database queries allows for cost and locale based distribution for execution of database queries. The database queries are executed on execution engines that provide flexible configuration and overlapping functionality. The system reduces various costs, including elapsed time, required to perform database queries. The system provides processing of a database query using a database catalog comprising database table locality information, record locality information and execution engine information. A query optimizer receives the query and accesses the database catalog to create a query execution plan comprising locality-based database operations. A central database operation processor providing a first execution engine executes the query execution plan by performing at least a portion of the locality-based database operations and distributing at least a portion of the locality-based database operations as a subplan. A second database operation processor providing a second execution engine executes the subplan received from the central database operation processor. At least one of the database operations can be executed on either the first execution engine or the second execution engine. A storage unit stores at least a portion of database tables and records. A data communications network connects the central database processor to the second database processor.

## Background
BACKGROUND OF THE INVENTION
This invention relates generally to systems for processing database queries, and more specifically to systems for processing database queries by creating a distributed locality, cost-based execution plan.
Database management systems (DBMS) manage data records stored on storage devices. The data is often distributed across multiple storage devices organized by a server and accessible over a network. A client presents a query, the DBMS processes the query and returns results to the client. These systems suffer from performance problems related to processor speed, memory speed, disk access time and network bandwidth.
Attempts to solve the performance problem of query processing in a distributed database environment can be generally characterized by three approaches: “fat pipe”, clustering and active disk.
The “fat pipe” solutions simply attempt to increase overall query processing performance by increasing the network bandwidth. No modification is made to the query processing itself, data and instructions just travel over a faster communications medium. Storage systems manufactured by EMC Corporation of Hopkinton, Mass. exemplify this approach.
Clustering of computers to perform database queries allows for parallel processing to occur. Parallel computer architectures generally fall into two categories: symmetric multiprocessing (SMP) and massively parallel processing (MPP). SMP systems contain multiple processors which share the same memory containing one copy of the computer application and data. SMP systems reduce transaction time by dividing computer operations into tasks which execute on assigned processors. MPP systems contain many processors, each with their own memory containing a copy of a portion or all of the computer application and/or data. Each processor can then work independently on its portion of the data to reduce overall transaction time. In database systems, data records can be striped across multiple disk drives connected to these clusters of computers. Each computer in a cluster can process parts of the database query on a group of data records that it has access to. Where “fat pipe” solutions attack the database query performance problem by increasing network bandwidth, clustering solutions attack the database query performance problem by increasing processing capacity. Oracle Corporation of Redwood Shores, Calif. provides an SMP clustering solution in its Oracle 8i database product.
A third approach to improving database query processing performance is “active disk” technology. Active disks combine computer processing with physically linked disk drives to provide parallel processing of database queries that also reduces the load on the communications network. This processing approach may be used to provide database management functionality on a processor closely linked to the database storage device. Conventional and proposed active disk systems only provide fixed functionality query processors and do not provide overlapping query processor functionality. Systems exemplifying this approach are described below.
A thesis by Eric Reidel entitled “Active Disks—Remote Execution for Network Attached Storage” (Technical Report CMU-CS-99-177, Pittsburgh, Pa., November 1999) describes disks with programmable processors. The thesis evaluates scan-based algorithms that allow for parallel processing of database queries. Reidel proposes a massively parallel processing (MPP) system using identical processors.
Another active disk system is described in a paper entitled “Active Disks: Programming Model, Algorithm and Evaluation” by Acharya (University of California Santa Barbara), Uysal (University of Maryland College Park) and Saltz (University of Maryland College Park) (Proceedings of the 8th International Conference on Architectural Support for Programming Languages and Operating Systems ASPLOS VIII, October 1998). The paper by Acharya et. al. describes a concept of moving processing closer to disks, but lacks a teaching of an overall database architecture outlining where and how all database operations are organized and optimally executed.
The 1999 doctoral dissertation by Kimberly Keeton of the University of California Berkeley, entitled “Computer Architecture Support for Database Applications” describes the concept of “intelligent disks” or “idisks” as an array of intelligent disk controllers. The idisks are user programmable processors and memory packaged on a disk storage device coupled to a high speed communications link. The idisks in the array can work together to provide parallel processing of database queries. Keeton only describes a single type of processor with non-overlapping functionality. Alternative future architectures are hinted at, but not enabled. Also at the University of California Berkeley research on introspective storage or “istore” has been done by David Patterson (http://istore.cs.berkeley.edu). Istore proposes the concept of intelligent disk “bricks” configured on a chassis having redundant components for “self-healing”. Each brick comprises a CPU, memory, redundant network interfaces and a disk drive. The istore architecture is similar to Keeton's idisk architecture and suffers from many of the same deficiencies.
Commercial attempts to provide improved speed for processing database queries include a system sold by Teradata, a division of NCR Corporation. Teradata provides classic MPP database query processing systems having two classes of fixed function processors. The first class of processors are Access Module Processors (AMP) which execute queries in parallel. The AMPs access data on directly attached disk drives. The second class of processors are InterFace Processors (IFP). The IFPs parse, optimize and direct execution of the database queries executed on the AMPs. IFPs and AMPs are connected using a redundant, tree-shaped interconnect. The AMP/IFP architecture provides only one type of execution processor without overlapping functionality capability and no multiple locale optimization or execution options. Teradata has evolved the hardware-based AMP/IFP architecture into a hardware/software architecture with nodes running software versions of the AMP and IFP processors, but the AMP and IFP processes still are restricted to the fixed functionality of the hardware-based architecture. The software-based architecture also does not provide multiple locale optimization or execution options.
SUMMARY OF THE INVENTION
The present invention provides a system for processing database queries that allows for cost and locale based distributed execution of database queries on a parallel, multi-locale processing system. The database queries are processed on execution engines that provide flexible processor configuration and overlapping processor functionality. The system reduces various costs, including elapsed time, required to perform database queries.
The present invention provides a system for processing a query on a database having a database catalog comprising database table locality information, record locality information, execution engine information, and characteristics of the various system components such as processing capabilities and performance. A query optimizer receives the query and accesses the database catalog to create a query execution plan comprising locality-based database operations. A first execution engine associated with a central database operation processor executes the query execution plan by performing at least a portion of the locality-based database operations and distributing at least a portion of the locality-based database operations to a second database operation processor as a subplan. A second execution engine associated with a second database operation processor executes the subplan received from the central database operation processor. At least one of the database operations can be executed on either the central execution engine or the second execution engine. Data is stored on a storage unit connected to the second database operation processor which stores at least a portion of database tables and records. A portion of the database tables and records may also be stored on a storage unit connected to the central database operation processor. A data communications network connects the central database processor to the second database operation processor.
Configurations of the present invention allow for the execution engines to process data received from the storage unit or the data communications network as a data stream. An execution engine can comprise any combination of processing devices and any number of processing devices. In one embodiment of the present invention an execution engine comprises a general purpose CPU and a Field Programmable Gate Array (FPGA). Alternate configurations of the execution engines comprise various combinations of one or more of a general purpose CPU, an FPGA, an Application Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), micro-controller, or other similar device. The processing devices can be arranged in a symmetric multiprocessing (SMP), massively parallel processing (MPP) or other configuration.
The present invention provides for many dynamic operations. In one particular embodiment, a query optimizer tracks performance results from queries and reallocates the database tables and records in order to create improved query execution. The execution engines dynamically track performance results from queries and modify the query execution plan to improve performance. The execution engines can also be dynamically reconfigured to process different database operations.
The present invention provides for storage units to be divided into sections and having locality information comprising: a section indicator indicating which section stores a database table, and a distribution indicator indicating whether the database table is striped or broadcast to the section.



BRIEF DESCRIPTION OF THE DRAWINGS
The foregoing and other objects, features and advantages of the invention will be apparent from the following more particular description of preferred embodiments of the invention, as illustrated in the accompanying drawings in which like reference characters refer to the same parts throughout the different views. The drawings are not necessarily to scale, emphasis instead being placed upon illustrating the principles of the invention.
FIG. 1 is a block diagram of a database appliance configured according to the principles of the present invention.
FIG. 2 is a block diagram of one of the Snippet Processing Units shown in FIG. 1.
FIG. 3 is an illustration of the logical components of a database appliance configured according to the principles of the present invention.
FIG. 4 is an illustration of the general execution plan distribution process.
FIG. 5 is an illustration of the distribution of a basic execution plan.
FIG. 6 is an illustration of an alternative distribution of a basic execution plan.
FIG. 7 is an illustration of a dynamically reconfigured execution plan.
FIG. 8 is an illustration of another alternative distribution of a basic execution plan.



DETAILED DESCRIPTION OF THE INVENTION
A description of preferred embodiments of the invention follows.
FIG. 1 is a block diagram of a database appliance 100 configured according to the principles of the present invention. The database appliance 100 includes a central database operation processor 106 for processing database requests received from a client 102 and a plurality of data storage units 108 storing portions of the database. In an embodiment shown, the data storage units 108 are disk drives, but the invention may use any alternative data storage technology. Each of the plurality of storage units 108 is coupled to a respective Snippet Processing Unit Controller 122 or central database operation processor CPU 120. The storage units and Snippet Processing Unit Controller may be connected electrically, optically or by any other data connection technology. The central database operation processor may be a separate device or an SPU may serve as a central database operation processor.
In one embodiment, each Snippet Processing Unit (SPU) 110 includes a respective Snippet Processing Unit Controller 122 and a respective storage unit 108. In an alternative embodiment, each Snippet Processing Unit Controller 122 may be associated with more than one storage unit 108. Each SPU is coupled to the central database operation processor 106 through a data communication network 112. This array of SPUs can be considered an MPP configuration.
The central database operation processor manages tables for the database stored in the plurality of storage units. Routines for managing and accessing records stored in the database are stored in central database operation processor memory 114 and portions of the database can be copied from the storage units and stored in central database operation processor memory or local storage. The central database operation processor receives database queries from the client 102 transmitted over a data communications network 112. A network interface component 116 in the central database operation processor receives the database queries. A network interface component may be a network interface card, switch or router, Fibre Channel transceiver, InfiniBand-enabled device, or other device programmed to transmit and receive messages according to standardized data network protocols.
A Central Processing Unit (CPU) 120 in the central database operation processor processes a received database query and forwards pieces of a query execution plan through a network interface component 116 over the data communications network 112 to the SPU storing the requested record. In an alternative embodiment, there are multiple CPUs configured as an SMP array. The piece of the query execution plan forwarded to either the central database operation processor execution engine or SPU for processing is referred as to a “snippet”. The snippet can include database operations such as join, sort, aggregate, restrict, reject, expression evaluation, statistical analysis or other operations. Database requests can be processed more efficiently by off-loading some of the processing from the central database operation processor to the SPUs.
Data records from one logical database table may be stored across multiple data storage units 108 using various distribution techniques. Storage units may be grouped into “sections,” each section consisting of one or more storage units. Sectioning is a logical grouping that may vary from table to table, i.e., the sectioning scheme associated with a given table may differ from the sectioning scheme associated with another table. The data records may be replicated to all data storage units 108, in a broadcast fashion. Alternately, certain data records may be stored on specific data storage units 108 or sections, in a striping fashion. The stored data records may also be mirrored across multiple data storage units 108 or sections for improved reliability and performance. A portion of the database tables and records may also be stored on a storage unit connected to the central database operation processor. The distribution technique may vary from table to table.
FIG. 2 is a block diagram of one of the Snippet Processing Units 110 shown in FIG. 1. The SPU 110 includes memory 206, a processing unit 201, a network interface component 204 coupled to the data communication network 112 and a storage controller interface 208 (e.g., an IDE controller interface) coupled to a storage controller 200 (e.g., IDE disk drive controller). Processing unit 201 includes a central processing unit 202 and can also include a programmable processing unit 203. The SPU Controller 122 is coupled to data storage 108 through storage controller interface 208. Data storage 108 (e.g., a disk subsystem) contains a storage controller 200 and a disk drive 218. A connection 212 (e.g., disk cable) couples connector 210a on the SPU Controller to connector 210b on the storage controller 200. In one embodiment, the storage controller interface is the American National Standards Institute (ANSI) AT Attachment interface (ATA), commonly referred to as the Integrated Drive Electronics (IDE) interface. The disk drive 218 stores database records. In other embodiments, the data storage units 108 may be replaced by a storage subsystem utilizing technologies other than disk drives, such as random access memory.
FIG. 3 is an illustration of the logical components of a database appliance configured according to the principles of the present invention. A database query 250 is presented to central database operation processor 106. The database query 250 may be initiated by any conventional source, such as a user, an interactive database query, a call through an application programming interface (API) or a system function. A database query is an instruction to process a data retrieval, manipulation or definition operation on a database. A popular language for expressing database queries is the Structured Query Language (SQL). The following examples of database queries will use SQL, although the principles of the present invention allow for processing of a database query written in any language.
A central database operation processor 106 is connected to multiple SPUs 110 through data communications network 112. There can be multiple central database operation processors 106 and data communication networks 112 in a database appliance 100.
A parser/validator 252 parses and checks the syntax of the database query 250. If the syntax is correct a query tree is produced, otherwise an error is generated. A query optimizer 254 takes the query tree as input and generates an execution plan 258 using metadata from the primary database catalog 256. A system optimizer 255 monitors data storage and execution plan 258 history in order to update the primary database catalog 256. Parts, or snippets, of the execution plan 258 are distributed and executed on various execution engines (e.g., central database operation processor execution engine 260, SPU execution engine 264 and programmable execution engine 270) within database appliance 100. The results of executing the snippets are aggregated on a central database operation processor execution engine (e.g., central database operation processor execution engine 260) and made available for further processing (e.g., printing).
Query optimizer/scheduler 254 creates an optimal execution plan by combining possible ways of scanning and joining tables that appear in the database query 250 to achieve the desired result. The execution plan comprises basic database processing steps including: scan data, project, restrict, sort, hash, group, join, distribute, return, broadcast, etc. Each step can be comprised of multiple substeps. Each step is associated with a locale (i.e., an execution engine). The query optimizer/scheduler 254 then chooses the optimal execution plan based on the processing capabilities, performance characteristics and current workloads of various components and the locality of the data records within the database appliance 100. Query optimizer/scheduler 254 can alter the query tree both in form (adding, deleting, rearranging) database operations and in content (modifying) database operations, in addition to assigning operations to various execution engines. Query optimizer/scheduler 254 calculates the optimal query plan based on the lowest cost by considering possible steps, possible locales and data table access variants for each step of the execution plan.
Primary database catalog 256 stores the performance characteristics of the various components and the locality of the data records within the database appliance 100. Performance characteristics include, for example, availability of specific database operations on the execution engine, execution engine processor speed, execution engine processor cache configuration, data disk speed, data disk controller speed, data disk controller interface bandwidth, memory availability, memory speed, network interface controller speed and network interface bandwidth. Locality information includes, for example, database table definitions, storage methods and database record count statistics. Using these characteristics and locality information, query optimizer 254 can analyze the costs associated with various execution plans in order to choose the optimal plan. The optimal execution plan is generally considered to be the execution plan that will take the least elapsed time to complete. Other definitions of optimal (e.g., minimize I/O seeks or fabric traffic) are possible and the query optimizer 254 can be configured to create execution plans based on alternative definitions of optimal.
Execution plan 258 is comprised of various parts (snippets). Snippets represent one or more database operations (e.g., scan, restrict, project, join, etc.) and a locality designation (e.g., central database operation processor, SPU, etc.). The snippets are distributed to the various execution engines for processing and the results are aggregated at a designated central database operation processor execution engine. The ability to distribute the snippets to different execution engines provides for parallel processing of database query 250. Parallel processing reduces the elapsed time to process the database query 250.
System optimizer 255 monitors data storage usage and requirements. As execution plans 258 are executed statistics are gathered and maintained in primary database catalog 256. System optimizer 255 maintains various usage statistics in order that query optimizer 254 can adjust execution plans 258 for optimal execution. System optimizer 255 is also used to detect reallocation thresholds and participates in planning for reallocation of data when certain predefined thresholds are met.
System components can also dynamically reconfigure the execution plan created by the system optimizer and redirect operations to other components as needed. For example, if an SPU cannot perform an assigned operation for any reason (such as running out of memory), the SPU can change the assigned locality (e.g., to the central database operation processor) of that operation and any dependent subsequent operations in the execution plan. Similarly, a central database operation processor could direct operations to SPUs.
Central database operation processor execution engine 260 provides processing for database operations including the aggregation of data from other database operations. Central database operation processor 106 is connected to the SPU 110 through data communication network 112.
SPU 110 receives a SPU execution plan 262 containing database operations to be performed on data records stored on data storage units 108. SPU execution engine 264 executes the database operations and/or distributes them to a programmable execution engine 270. SPU execution engine 264 accesses a supplemental database catalog 266 to determine optimal distribution, in the same fashion the query optimizer 254 accesses primary database catalog 256. The resulting programmable engine execution plan 268 is then executed on programmable execution engine 270.
In one particular embodiment, the programmable execution engine 270 is a field programmable gate array (FPGA) configured specifically to perform certain database operations. Using input parameters, the FPGA can be reconfigured to perform various database operations selected from a set of preprogrammed operations. In another embodiment, programmable execution engine 270 is an application specific integrated circuit (ASIC) specifically configured to perform various database operations. Both the FPGA and ASIC implementations allow for increased speed in the execution of database operations as actual database instructions can be implemented in hardware/firmware. In other embodiments, various combinations of general purpose CPU, FGPA and ASIC, as well as other processing devices, can be used to implement the SPU execution engine 264 and programmable execution engine 270 without departing from the scope of the present invention.
The various execution engines within database appliance 100 provide for distributing database functionality in a flexible manner. Each execution engine can execute many different database operations. The configuration of the database engines is maintained in the database catalogs, thereby allowing the query optimizer 254 to adjust the generation of execution plans 258 as the configuration of the execution engines changes. This flexibility allows for the dynamic reconfiguration of database records and database operations to suit specific performance needs without affecting the underlying operation of query optimizer 254. In this way database operations are executed by the most appropriate execution engine. For example, for a given query, record scanning maybe done on SPU execution engine 264, restriction operations may be done on programmable execution engine 270 and join operations may be done on central database operation processor execution engine 260.
The present invention provides overlapping functionality of database operations, as the various execution engines (central database operation processor execution engine 260, SPU execution engine 264, programmable execution engine 270) provide a subset of database operations. Because database appliance 100 provides for flexible distribution of database operation execution, multiple execution engines can provide overlapping functionality that is invoked based on external factors (e.g., data record layout, number of data records, performance characteristics of the execution engines, etc.).
FIG. 4 is an illustration of the general execution plan distribution process. Generally, an execution plan 300 is produced as the result of a database query being processed by a parser/validator and a query optimizer 254. The execution plan is then broken into execution subplans (e.g., distributed execution plan 302, distributed execution subplan 304 and distributed execution subplan 306). Because of the flexibility and overlapping functionality of database appliance 100 each execution subplan can be distributed and executed on a variety of subplan execution engines (e.g., subplan execution engine 308, subplan execution engine 310 and subplan execution engine 312).
As an aid in the illustration of a distribution of a basic execution plan a store sales database example will be presented that defines a Sales data table and a SalesDetail data table as follows:
Sales

    
    
        TransactionID
        SaleDate
        StoreLocation
    
    


SalesDetail

    
    
        TransactionID
        ProductCategory
        Units
        Amount
    
    


A sample query on the store sales database may be “show me the total units and dollar amount of rain gear sold in North Carolina in 2000, by month.” This can be translated into the SQL statement:












SELECT Month(Sales.SaleDate) AS “Month”,









Sum(SalesDetail.Units) AS “Sales units”,



Sum(SalesDetail.Amount) AS “Sales amount”







FROM Sales, SalesDetail


WHERE Sales.TransactionlD = SalesDetail.TransactionID









AND Sales.StoreLocation = “NC” AND Year(Sales.SaleDate)=“2000”



AND SalesDetail.ProductCategory = “Raingear”







GROUP BY Month(Sales.SaleDate)









The output from the sample query showing the total units and dollar amount of rain gear sold in North Carolina in 2000 by month can be shown in tabular format:















Month
Sales Units
Sales Amount




















January
1,300
$45,000



February
1,200
$41,000



March
1,800
$60,000



April
3,500
$98,000



May
4,200
$112,000



June
5,000
$150,000



July
4,700
$143,000



August
4,100
$104,000



September
3,600
$101,000



October
2,000
$65,000



November
1,200
$41,000



December
1,500
$43,000










In a particular embodiment, the database appliance 100 can be configured to provide for the distribution of database operation execution for this query as follows:











Execution Engine
Database Operation







Central database operation
GROUP 358, AGGREGATE 362,


processor execution engine
ORDER 360, PROJECT 354, JOIN 356,


(CDBP) 260
SAVE 364


SPU execution engine
SCAN 352, PROJECT 354, JOIN 356,


(SPU) 264
GROUP 358, SAVE 364


Programmable execution
RESTRICT 350


engine (PXE) 270









FIG. 5 is an illustration of the distribution of a basic execution plan. Using the above example a basic execution plan can be created by query optimizer 254 that performs joins on the SPU execution engine 264 and performs aggregate functions on the SPU execution engine 264 and central database operation processor execution engine 260, with restriction functions being performed on the programmable execution engine (PXE) 270.











Locale
Operation







SPU
SCAN SaleDetail


PXE
RESTRICT ProductCategory = “Raingear”


SPU
PROJECT TransactionID, Units, Amount


SPU
SAVE As TEMPDetail


SPU
SCAN Sale


PXE
RESTRICT StoreLocation = “NC” AND 



Year(SaleDate)=“2000”


SPU
PROJECT TransactionID, Month(SaleDate) As “Month”


SPU
JOIN WITH TEMPDetail,



TransactionID=TEMPDetail.TransactionID


SPU
PROJECT Month, TEMPDetail.Units As “Units”



TEMPDetail.Amount As “Amt”


SPU
GROUP By Month


SPU
AGGREGATE Sum(Units) As “Units”, Sum(Amt) As



“AmtTotal”


SPU
RETURN


CDBP
GROUP By Month


CDBP
AGGREGATE Sum(Units) As “Sales Units”, Sum(AmtTotal)



As “Sales amount”


CDBP
ORDER BY Month


CDBP
PROJECT Month, “Sales Units”, “Sales amount“


CDBP
RETURN









FIG. 6 is an illustration of an alternative distribution of a basic execution plan. Here joins are performed on the SPU execution engine 264 and aggregate functions are performed on the central database operation processor execution engine 260.











Locale
Operation







SPU
SCAN SalesDetail


PXE
RESTRICT ProductCategory = “Raingear”


SPU
PROJECT TransactionID, Units, Amount


SPU
SAVE As TEMPDetail


SPU
SCAN Sales


PXE
RESTRICT StoreLocation = “NC” AND Year(SaleDate)=



“2000”


SPU
PROJECT TransactionID, Month(SaleDate) As “Month”


SPU
JOIN WITH TEMPDetail,



TransactionID=TEMPDetail.TransactionID


SPU
PROJECT TransactionID,Month, TEMPDetail.Units As



“Units”,TEMPDetail.Amount As“Amt”


SPU
RETURN


CDBP
GROUP By Month


CDBP
AGGREGATE Sum(Units) As “Sales Units”, Sum(Amt) As



“Sales amount”


CDBP
ORDER BY Month


CDBP
PROJECT Month, “Sales Units”, “Sales amount”


CDBP
RETURN









FIG. 7 is an illustration of a dynamically reconfigured execution plan showing how a system component can dynamically reconfigure the execution plan described in conjunction with FIG. 6 in response to a problem. For purposes of this example, assume that, for this query, an SPU is unable to perform all of its assigned operations (e.g., due to running out of memory) and, as a result, redirects some operations to the central database operation processor.











Locale
Operation







SPU
SCAN SalesDetail


PXE
RESTRICT ProductCategory = “Raingear”


SPU
PROTECT TransactionID, Units, Amount


SPU
SAVE As TEMPDetail {This operation fails due to lack



of memory}


SPU
RETURN


CDBP
SAVE As TEMPDetail


SPU
SCAN Sales


PXE
RESTRICT StoreLocation = “NC” AND



Year(SaleDate)=“2000”


SPU
PROJECT TransactionID, Month(SaleDate) As “Month”


SPU
RETURN


CDBP
JOIN WITH TEMPDetail,



TransactionID=TEMPDetail.TransactionID


CDBP
PROJECT TransactionID,Month, TEMPDetail.Units As



“Units”,TEMPDetail.Amount As“Amt”


CDBP
GROUP By Month


CDBP
AGGREGATE Sum(Units) As “Sales Units”, Sum (Amt) as



“Sales amount”


CDBP
ORDER By Month


CDBP
PROJECT Month, “Sales Units”, Sales amount”


CDBP
RETURN









FIG. 8 is an illustration of another alternative distribution of a basic execution plan. Here join and aggregate functions are performed on the central database operation processor execution engine 260.











Locale
Operation







SPU
SCAN SaleDetail


PXE
RESTRICT ProductCategory = “Raingear”


SPU
PROJECT TransactionID, Units, Amount


SPU
RETURN


CDBP
SAVE As TEMPDetail


SPU
SCAN Sale


PXE
RESTRICT StoreLocation = “NC” AND



Year(SaleDate)=“2000”


SPU
PROJECT TransactionID, Month(SaleDate) As “Month”


SPU
RETURN


CDBP
JOIN WITH TEMPDetail,



TransactionID=TEMPDetail.TransactionID


CDBP
PROJECT Month, TEMPDetail.Units As “Units”,



TEMPDetail.Amount As“Amt”


CDBP
GROUP By Month


CDBP
AGGREGATE Sum(Units) As “Sales Units”, Sum(Amt)



As “Sales amount”


CDBP
ORDER BY Month


CDBP
PROJECT Month, “Sales Units”, “Sales amount”


CDBP
RETURN









While this invention has been particularly shown and described with references to preferred embodiments thereof, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the scope of the invention encompassed by the appended claims. A database query is meant to encompass all data manipulation (e.g., select, insert, delete and update) and data definition (e.g., create table, drop table) instructions.

## Claims

1. A system for processing a query on a database comprising:
a database catalog comprising database table locality information, record locality information, execution engine information and characteristics of the system components;
a query optimizer receiving the query and accessing the database catalog to create a query execution plan comprising locality-based database operations, the locality-based database operations in the query execution plan thus specifying a database operation as well as a processor locale from among multiple possible locales for each such database operation;
a central database operation processor providing a first execution engine as a first type of locale for executing database operations as specified by the query execution plan, by performing at least a portion of the locality-based database operations as specified by the query execution plan and distributing at least some other portions of the locality-based database operations as a subplan;
a second database operation processor providing a second execution engine as a second locale for executing portions of the query execution plan as specified by the subplan received from the central database operation processor, wherein the second execution engine locale has at least some different operation processing capabilities than the first execution engine locale, to provide a second type of locale for executing database operations;
a storage unit storing at least a portion of database tables and records connected to at least one of the central database operation processor and the second database operation processor;
a data communications network connecting the central database operation processor to the second database operation processor;
program means for comparing the processing capabilities of the first and second locale types for the database operation; and
means for changing the query execution plan, to direct specific database operations to the locales determined by the means for comparing.

2. The system of claim 1 wherein the central database operation processor is configured as a symmetric multi-processing system and the second database operation processor is configured as a component of a massively parallel processing system.

3. The system of claim 1 wherein the first execution engine or the second execution engine processes data records received from the storage unit by performing one or more operations on the data records without materializing the data record into a memory.

4. The system of claim 1 wherein the first execution engine or the second execution engine processes data records received from the data communications network by performing one or more operations on the data records without materializing the data record into a memory.

5. The system of claim 1 wherein the first execution engine locale and the second execution engine locale have different processing capabilities selected from a group of processing capabilities consisting of execution engine memory, execution engine processor speed, cache configuration, disk speed, disk controller speed, disk controller bandwidth, network interface bandwidth or network interface speed.

6. The system of claim 1 wherein the storage unit is electrically connected to the second database operation processor.

7. The system of claim 1 wherein the storage unit is optically connected to the second database operation processor.

8. The system of claim 1 wherein the storage unit is a disk drive.

9. The system of claim 1 wherein the storage unit is a random access memory.

10. The system of claim 1 wherein a portion of the database is stored on a storage unit connected to the central database operation processor.

11. The system of claim 1 wherein the first execution engine or the second execution engine reconfigures an executing subplan to redirect one or more operations to another execution engine.

12. The system of claim 1 wherein each execution engine comprises a plurality of processing devices.

13. The system of claim 1 wherein each execution engine comprises a combination of processing devices.

14. The system of claim 13 wherein the execution engine comprises a general purpose central processing unit and a field programmable gate array.

15. The system of claim 13 wherein the execution engine comprises a general purpose central processing unit and an application specific integrated circuit.

16. The system of claim 13 wherein the execution engine comprises a field programmable gate array and an application specific integrated circuit.

17. The system of claim 1 wherein a plurality of the storage units are grouped into sections and the locality information comprises:
a section indicator indicating which section stores a database table; and
a distribution indicator indicating whether the database table is striped or replicated to the section.

18. The system of claim 1 wherein a system optimizer tracks performance results from the query and reallocates the database tables and records across the storage units in order to improve query execution.

19. The system of claim 18 wherein the reallocation comprises striping the database tables and records across the storage units.

20. The system of claim 18 wherein the reallocation comprises replicating the database tables and records across the storage units.

21. The system of claim 1 wherein at least one of the first execution engine or the second execution engine dynamically track performance results from the executing queries and modify the query execution plan to improve performance.

22. The system of claim 1 wherein the execution engines dynamically track system configuration and resource utilization from the executing queries and modify the query execution plan to improve system resource utilization.

23. The system of claim 1 wherein at least one of the first execution engine or the second execution engine are dynamically reconfigured to process different database operations.

24. The system of claim 1 wherein the storage unit is directly connected to the second database operation processor, without using a data network connection.

25. The system of claim 1 wherein access to the storage unit is exclusive to a predetermined second database processor, such that other database processors cannot access the storage unit.

26. A system as in claim 1 wherein the query execution plan is developed by the central database operation processor.

27. A system as in claim 1 wherein selection of execution locale for the operation is made before or during query execution.

28. A system as in claim 1 wherein the execution engine locale type at which such specific database operation is actually executed is additionally chosen by comparing operating conditions of the first and second locale types.

29. A system as in claim 28 wherein the operating conditions comprise a measure of resource utilization.

30. A system as in claim 29 wherein the resource is selected from a group consisting of execution engine memory, execution engine processor speed, cache configuration, disk speed, disk controller speed, disk controller bandwidth, network interface bandwidth or network interface speed.

31. A method for generating a distributed locality-based execution plan comprising:
receiving a database query;
parsing and validating the database query to produce a query tree; and
optimizing the query tree to produce a locality-based execution plan by accessing a database catalog comprising database table locality information, record locality information and execution engine information, the locality-based execution plan thus being a plan containing multiple locality-based database operations, and the plan specifying a processing locale type for each database operation in the plan from among multiple possible database execution engine locale types, with at least one type of database operation being optionally executable on either a first execution engine locale type or a second execution engine locale type, with the first execution engine locale type having at least some different processing capabilities than the second execution engine locale type;
executing first portions of the locality-based execution plan on at least one execution engine which is a first type of execution engine, the first portions being designated by the plan as having a locale which specifies the first execution engine locale type;
distributing second portions of the locality-based execution plan as a subplan to a second database execution engine which is a second type of execution engine, the second portions designated by the plan as having a locale which specifies the second execution engine locale type;
comparing the processing capabilities of the first and second locale types for the database operation; and
changing the query execution plan, to direct specific database operations to the locales determined by the step of comparing.

32. An apparatus for generating a distributed locality-based execution plan comprising:
means for receiving a database query;
means for parsing and validating the database query to produce a query tree; and
means for optimizing the query tree to produce a locality-based execution plan by accessing a database catalog comprising database table locality information, record locality information and execution engine information, the locality-based execution plan thus being a plan containing multiple locality-based database operations, and the plan specifying a processing locale type for each database operation in the plan from among multiple possible database execution engine locale types, with at least one type of database operation being optionally executable on either a first execution engine locale type or a second execution engine locale type, with the first execution engine locale type having at least some different processing capabilities than the second execution engine locale type;
executing first portions of the locality-based execution plan on at least one execution engine which is a first type of execution engine, the first portions being designated by the plan as having a locale which specifies the first execution engine locale type;
distributing second portions of the locality-based execution plan as a subplan to a second database execution engine which is a second type of execution engine, the second portions designated by the plan as having a locale which specifies the second execution engine locale type; and
comparing the processing capabilities of the first and second locale types for the database operation; and
changing the query execution plan, to direct specific database operations to the locales determined by the step of comparing.

33. A computer program product comprising:
a computer usable medium for generating a distributed locality-based execution plan;
a set of computer program instructions embodied on the computer usable medium, including instructions to:
receive a database query;
parse and validating the database query to produce a query tree; and
optimize the query tree to produce a locality-based execution plan by accessing a database catalog comprising database table locality information, record locality information and execution engine information, the locality-based execution plan thus being a plan containing multiple locality-based database operations, and the plan specifying a processing locale type for each database operation in the plan from among multiple possible database execution engine locale types, with at least one type of database operation being optionally executable on either a first execution engine locale type or a second execution engine locale type, with the first execution engine locale type having at least some different processing capabilities than the second execution engine locale type;
executing first portions of the locality-based execution plan on at least one execution engine which is a first type of execution engine, the first portions being designated by the plan as having a locale which specifies the first execution engine locale type;
distributing second portions of the locality-based execution plan as a subplan to a second database execution engine which is a second type of execution engine, the second portions designated by the plan as having a locale which specifies the second execution engine locale type;
comparing the processing capabilities of the first and second locale types for the database operation; and
changing the query execution plan, to direct specific database operations to the locales determined by the step of comparing.

34. A system for processing a query on a database comprising:
a plurality of database operation processor components, with at least two of the database operation processor components having different operation processing capabilities, such that the database operation processor components provide at least two different locales for executing database operations, with the two locales having different operation processing capabilities and such that more than one database operation processor component locale is capable of executing a given selected database operation;
a database catalog comprising database table information, database operation processor component locale information, and database operation processor characteristic information;
a query optimizer receiving the query and accessing the database catalog to develop a query execution plan, the query execution plan defining a list of database operations to carry out the query, and the query execution plan also defining a respective database operation processor component locale at which to carry out each such database operation in the query execution plan, program means for comparing the processing capabilities of the first and second locale types for the database operation; and
means for changing the query execution plan, to direct specific database operations to the locales determined by the means for comparing.

35. A system as in claim 34 additionally comprising:
a central database operation processor comprising a first execution engine to provide a first one of the database operation components;
a second database operation processor comprising a second execution engine to provide a second one of the database operation components;
a storage unit storing at least a portion of database tables and records connected to at least one of the central database operation processor and the second database operation processor; and
a data communications network connecting the central database operation processor to the second database operation processor.

36. The system of claim 35 wherein the central database operation processor is configured as a symmetric multi-processing system and the second database operation processor is configured as a component of a massively parallel processing system.

37. The system of claim 35 wherein the first execution engine or the second execution engine processes data records received from the storage unit by performing one or more operations on the data records without materializing the data record into a memory.

38. The system of claim 35 wherein the first execution engine or the second execution engine processes data records received from the data communications network by performing one or more operations on the data records without materializing the data record into a memory.

39. The system of claim 35 wherein the first execution engine and the second execution engine have at least some different processing capabilities.

40. The system of claim 35 wherein the first execution engine or the second execution engine reconfigures an assigned execution subplan to redirect one or more operations to another execution engine.

41. The system of claim 35 wherein first execution engine comprises a general purpose central processing unit and a field programmable gate array.

42. The system of claim 35 wherein second execution engine comprises a general purpose central processing unit and an application specific integrated circuit.

43. The system of claim 35 wherein a system optimizer tracks performance results from the query and reallocates the database tables and records across the storage units in order to improve query execution.

44. The system of claim 43 wherein the reallocation comprises striping the database tables and records across the storage units.

45. The system of claim 43 wherein the reallocation comprises replicating the database tables and records across the storage units.

46. The system of claim 35 wherein at least one of the first execution engine or the second execution engine dynamically track performance results from the executing queries and modify a query execution plan to improve performance.

47. The system of claim 35 wherein the execution engines dynamically track system configuration and resource utilization from the executing queries and modify the query execution plan to improve system resource utilization.

48. The system of claim 35 wherein at least one of the first execution engine or the second execution engine are dynamically reconfigured to process different database operations.

49. A system for processing a query on a database comprising:
a plurality of database operation processor components, with at least two of the database operation processor components have different operation processing capabilities, and such that more than one database operation processor component is capable of executing a given database operation;
a database catalog comprising database table information, database operation processor component locale information, and database operation processor characteristic information;
a query optimizer receiving the query and accessing the database catalog to develop a query execution plan, the query execution plan defining a list of database operations to carry out the query, and the query execution plan also defining a respective database operation processor component locale for each such database operation from among multiple possible such locales; and
wherein at least one of the execution engines dynamically tracks resource utilization during execution of the query, while the database operations are still being executed by the database operation processor components, so that the query plan is dynamically re-optimized while the query plan is being executed, and thereby modifying the locales originally specified by the query execution plan to optimize performance.

50. A system as in claim 49 wherein the resource tracked is selected from a group consisting of execution engine memory, execution engine processor speed, cache configuration, disk speed, disk controller speed, disk controller bandwidth, network interface bandwidth or network interface speed.

51. A system as in claim 49 wherein the plurality of database operation components further comprises:
a central database operation processor comprising a first execution engine to provide a first one of the database operation components;
a second database operation processor comprising a second execution engine to provide a second one of the database operation components;
a storage unit storing at least a portion of database tables and records connected to at least one of the central database operation processor and the second database operation processor; and
a data communications network connecting the central database operation processor to the second database operation processor.

52. The system of claim 51 wherein the central database operation processor is configured as a symmetric multi-processing system and the second database operation processor is configured as a component of a massively parallel processing system.

53. The system of claim 51 wherein the first execution engine or the second execution engine reconfigures an assigned execution subplan to redirect one or more operations to another execution engine.

54. The system of claim 51 wherein a system optimizer tracks performance results from the query and reallocates the database tables and records across the storage units in order to improve query execution.

55. The system of claim 54 wherein the reallocation comprises striping the database tables and records across the storage units.

56. The system of claim 54 wherein the reallocation comprises replicating the database tables and records across the storage units.

57. The system of claim 51 wherein at least one of the first execution engine or the second execution engine dynamically track performance results from the executing queries and modify a query execution plan to improve performance.

58. The system of claim 51 wherein the execution engines dynamically track system configuration and resource utilization from the executing queries and modify the query execution plan to improve system resource utilization.

59. The system of claim 51 wherein the dynamically re-optimized plan specifies that at least one of the first execution engine or the second execution engine are dynamically reconfigured to process different database operations.

60. A system as in claim 49 wherein the database catalog further includes, for at least a specified one of the database operation components, configuration information that specifies a set of preprogrammed database operations that can be carried out by the specified database processor component.

61. A system as in claim 60 wherein the query optimizer further determines a smaller set of performable database operations for the specified component selected from the larger set of preprogrammed database operations, and the query optimizer further selecting only from the set of performable database operations when determining portions of the query execution plan to be carried out for the specified component.

62. A system as in claim 61 wherein the set of performable database operations can be modified for the specified component while the query plan is being executed.

63. A system as in claim 62 wherein the query optimizer adjusts the generation of the re-optimized query plan to take into account the change in configuration of the specified component, with the re-optimized query plan thus using the modified set of performable database operations.

64. The system of claim 51 wherein the dynamically re-optomized plan specifies that at least one of the first execution engine or the second execution engine processes a different database operation than that respective execution engine executed in the query execution plan prior to its re-optimization.

65. A system for processing a query on a database comprising:
a plurality of database operation processor components, with at least two of the database operation processor components having different operation processing capabilities, and such that on more than one database operation processor component is capable of executing a selected database operation;
a database catalog comprising database table information, database operation processor component locale information, and database operation processor characteristic information;
a query optimizer, running on a first database operation processor component, for receiving the query and accessing the database catalog to develop a query execution plan, the query execution plan defining a list of database operations to carry out the query, the query execution plan also defining a respective database operation processor component locale for each such database operation;
wherein the first database operation processor component not only executes portions of the query execution plan designated to be handled itself but also forwards at least a selected portion of the query execution plan to a second database operation processor component having different operation processing capabilities than the first database operation processor component; and
wherein the second database operation processor component executes portions of the query execution plan designated for itself, and also forwards other selected portions of the query execution plan to a third database operation component for execution,
and further wherein the plurality of the database operation processor components further comprise:
a central database operation processor comprising a first execution engine to provide a first one of the database operation components;
a second database operation processor comprising a second execution engine to provide a second one of the database operation components;
a storage unit storing at least a portion of database tables and records connected to at least one of the central database operation processor and the second database operation processor; and
a data communications network connecting the central database operation processor to the second database operation processor
wherein either the first execution engine or the second execution engine dynamically reconfigures an assigned execution subplan to redirect one or more operations to the third execution engine, so that the query execution plan is re-optimized while still being executed.