The invention relates generally to data access middleware, and in particular to a system and method of query transformation.
A typical data access environment has a multi-tier architecture. For description purposes, it can be separated into three distinct tiers:
The web server contains a firewall and one or more gateways. All web communication is performed through a gateway. A gateway is responsible for passing on requests to the application server, in tier 2, for execution.
The applications tier contains one or more application servers. The application server runs requests, such as reports and queries that are forwarded by a gateway running on the web server. Typically, one of the components of the applications tier is a query engine, which is data access middleware that provides universal data access to a variety of heterogeneous database systems. The query engine formulates queries (typically SQL) and passes them on to the data tier, through a native database API (such as ODBC) for execution.
The data tier contains database management systems (DBMS), which manage raw data stored in a database. Examples of such systems include Oracle, DB2, and Microsoft SQL Server.
Although a multi-tier architecture can be configured in several different ways, a typical configuration places each tier on a separate computer (server). A database server is typically a “high end” server, and thus can process queries at a relatively fast speed. An application server cannot generally process queries as quickly as a database server.
In order to solve many business questions, a query engine may generate SQL queries that utilize the SQL/OLAP technology introduced in the SQL: 1999 standard. However, many database systems do not support this technology. Thus, the SQL queries would have to be performed by the query engine on the application server that is generally slower than the database server. It is desirable to have as much processing performed on the database server as possible.
There is a need to prevent or reduce the amount of local (application server) processing required to process a query. In the past, the application would be responsible for generating SQL that contained a standard GROUP BY query. Quite often, generating this type of SQL is more difficult since it is more complex.
One way of overcoming this problem is for the query engine to generate a GROUP BY query to compute aggregates at the lowest level of granularity, and then compute the remaining aggregates based on these values. This approach reduces the amount of processing time required on the application server.
It is an object of the present invention to provide a method of Client/Server Aggregate query transformation in a database system that does not support SQL: 1999 standard.
In accordance with an embodiment of the present invention, there is provided a system for transforming client/server aggregates. The system comprises a client/server analysis component for analyzing one or more queries that are not supported by a target database system, and a client/server transformation component for transforming the one or more queries into semantically equivalent queries that are supported by the target database system.
In accordance with another embodiment of the present invention, there is provided a method of client/server aggregate transformation. The method comprises the steps of analyzing one or more queries that are not supported by a target database system, and transforming the one or more queries into semantically equivalent queries that are supported by the target database system.
In accordance with another embodiment of the present invention, there is provided a method of client/server aggregate transformation. The method comprises the steps of analyzing a client/server select list to determine if a transformation is to be performed, generating a derived table, traversing all expressions in the main select list, adding columns or expressions that are grouping columns to the derived table select list, and converting and moving eligible aggregates into the derived table select list.
In accordance with another embodiment of the present invention, there is provided a computer data signal embodied in a carrier wave and representing sequences of instructions which, when executed by a processor, cause the processor to perform a method of client/server aggregate transformation. The method comprises the steps of analyzing one or more queries that are not supported by a target database system, and transforming the one or more queries into semantically equivalent queries that are supported by the target database system.
In accordance with another embodiment of the present invention, there is provided a computer-readable medium having computer readable code embodied therein for use in the execution in a computer of a method of client/server aggregate transformation. The method comprises the steps of analyzing one or more queries that are not supported by a target database system, and transforming the one or more queries into semantically equivalent queries that are supported by the target database system.
In accordance with another embodiment of the present invention, there is provided a computer program product for use in the execution in a computer of a query transformation system for transforming client/server aggregates. The computer program product comprises a client/server analysis component for analyzing one or more queries that are not supported by a target database system, and a client/server transformation component for transforming the one or more queries into semantically equivalent queries that are supported by the target database system.
In order to solve many business questions, a query engine 15 generates SQL queries that utilize the SQL/online analytical programming (OLAP) technology introduced in the SQL: 1999 standard. These SQL queries include SQL/OLAP functions (windowed aggregates). However, many database systems 12 do not support this technology. In order to prevent or reduce the amount of local (application server) processing required to process these types of queries, the query engine 15 attempts to generate semantically equivalent queries that can be processed in whole or in part on the database server 12 by the target database system. These semantically equivalent queries involve standard aggregate functions and the GROUP BY operator.
The Client/Server Aggregate transformation system 20 is implemented as a sub-system of the query engine 15 in the data access environment 10. This transformation 20 may generate queries that can be processed in their entirety on the database server 12, or queries that require processing on both the application server 13 and the database server 12.
Advantageously, the Client/Server Aggregate transformation system 20 reduces processing that might otherwise be required on the application server by generating a semantically equivalent query, thereby improving performance in many cases. Furthermore, the Client/Server Aggregate transformation system 20 takes advantage of functionality provided by the target database. In particular, the Client/Server Aggregate system 20 utilizes the functionality provided by standard aggregates and the GROUP BY operator.
There are two types of OLAP functions: framed functions and report functions. Framed OLAP functions contain a window frame specification (ROWS or RANGE) and an ORDER BY clause. Through window frames, capabilities such as cumulative (running) sums and moving averages can be supported. Report functions do not contain a window frame specification, and produce the same value for each row in a partition.
The Client/Server Aggregate transformation attempts to reduce the number of derived tables generated in a SQL group transformation by computing some of the aggregates locally. This transformation can be utilized when the user is willing to tolerate some (local) processing on the application server.
To determine if the transformation can be performed, all expressions and aggregates in the select list are analyzed. This analysis consists of the following:
In performing the transformation, the following assumptions are made:
Given these assumptions, the basic steps in performing the transformation are as follows:
For the purpose of discussion, assume the target database for the following examples does not support the SQL/OLAP technology introduced in the SQL: 1999 standard. The native SQL shown in each example is the SQL passed to the target database.
In this example, multiple SUM functions with compatible control breaks are present, so the transformation is straightforward.
Explanation
The original query contains OLAP SUM functions computed over the partitions ( ), (SNO), and (SNO, PNO). Because of the presence of the DISTINCT keyword, and the fact that the detail columns (SNO and PNO) are pan of a PARTITION BY clause, the query can be rewritten using a single derived table that computes the sum with the finest granularity (SNO, PNO). The remaining SUM functions can be computed based on this value, as shown in the transformed query.
In this example, multiple SUM functions with compatible control breaks are present, but an AVG function has been introduced, making the transformation a little more complex.
Explanation
The original query contains OLAP SUM functions computed over the partitions ( ), (SNO), and (SNO, PNO). It also contains an OLAP AVG function computed over the partition ( ). Because of the presence of the DISTINCT keyword, and the fact that the detail columns (SNO and PNO) are pan of a PARTITION BY clause, the query can be rewritten using a single derived table that computes the sum with the finest granularity (SNO, PNO). The remaining SUM functions can be computed based on this value, as shown in the transformed query. This value can be used to compute the average as well. However, we also require a count to be computed at the lowest level of granularity. The final average is then computed as shown in the transformed query (average of an average will not work).
In this example, the OLAP functions SUM and AVG have identical control breaks corresponding to the required detail information (SNO, PNO), so the entire query can be replaced with a simple GROUP BY query.
Explanation
The original query contains two OLAP functions computed over the partition (SNO, PNO). This partition represents the grouping columns in the transformed query. Because of the presence of the DISTINCT keyword, and the fact that the detail columns (SNO and PNO) are grouping columns, the query can be rewritten as a simple GROUP BY query.
In this example, the OLAP functions SUM and AVG have identical control breaks corresponding to the required detail information (SNO, PNO), so the entire query can be replaced with a simple GROUP BY query.
Explanation
The original query contains two SUM functions computed over the partitions ( ) and (SNO); The longest control break (SNO), however, does nor correspond to the detail information required (SNO, PNO). Hence, the derived table generated consists of a GROUP BY query that computes a sum grouped on (SNO, PNO). Both of the outer sum values are then computed based on this value.
A system for query transformation may comprise an analysis component and a transformation component. The analysis component may comprise a Nested Aggregate analysis module, a SQL GROUP transformation analysis module, a summary filter transformation analysis module, and a Summary Filler analysis module. The transformation component may comprise a Nested Aggregate transformation module, a SQL GROUP transformation module, a Client/Server Aggregate transformation module, and a Summary Filter transformation module.
The systems and methods according to the present invention may be implemented by any hardware, software or a combination of hardware and software having the functions described above. The software code, either in its entirety or a pan thereof, may be stored in a computer readable memory. Further, a computer data signal representing the software code that may be embedded in a carrier wave may be transmitted via a communication network. Such a computer readable-memory and a computer data signal are also within the scope of the present invention, as well as the hardware, software and the combination thereof.
While particular embodiments of the present invention have been shown and described, changes and modifications may be made to such embodiments without departing from the true scope of the invention.
| Number | Date | Country | Kind |
|---|---|---|---|
| 2429910 | May 2003 | CA | national |
The present application is a continuation application claiming priority from U.S. application Ser. No. 10/856,306, filed May 27, 2004, now U.S. Pat. No. 7,428,532, the content of which is incorporated by reference herein in its entirety.
| Number | Name | Date | Kind |
|---|---|---|---|
| 5963936 | Cochrane et al. | Oct 1999 | A |
| 6009432 | Tarin | Dec 1999 | A |
| 6128612 | Brereton et al. | Oct 2000 | A |
| 6289334 | Reiner et al. | Sep 2001 | B1 |
| 6339775 | Zamanian et al. | Jan 2002 | B1 |
| 6341281 | MacNicol et al. | Jan 2002 | B1 |
| 6345272 | Witkowski et al. | Feb 2002 | B1 |
| 6370524 | Witkowski | Apr 2002 | B1 |
| 6370541 | Chou et al. | Apr 2002 | B1 |
| 6438537 | Netz et al. | Aug 2002 | B1 |
| 6460027 | Cochrane et al. | Oct 2002 | B1 |
| 6519604 | Acharya et al. | Feb 2003 | B1 |
| 6567802 | Popa et al. | May 2003 | B1 |
| 6574623 | Leung et al. | Jun 2003 | B1 |
| 6609123 | Cazemier et al. | Aug 2003 | B1 |
| 6611838 | Ignat et al. | Aug 2003 | B1 |
| 6629094 | Colby et al. | Sep 2003 | B1 |
| 6651055 | Kilmer et al. | Nov 2003 | B1 |
| 6684204 | Lal | Jan 2004 | B1 |
| 6714928 | Calow | Mar 2004 | B1 |
| 6766330 | Chen et al. | Jul 2004 | B1 |
| 6847962 | Cochrane et al. | Jan 2005 | B1 |
| 6934712 | Kiernan et al. | Aug 2005 | B2 |
| 6985895 | Witkowski et al. | Jan 2006 | B2 |
| 7110999 | Colby et al. | Sep 2006 | B2 |
| 7120645 | Manikutty et al. | Oct 2006 | B2 |
| 7133865 | Pedersen et al. | Nov 2006 | B1 |
| 7275056 | Cheng et al. | Sep 2007 | B2 |
| 7315849 | Bakalash et al. | Jan 2008 | B2 |
| 7318058 | Styles | Jan 2008 | B2 |
| 7428532 | Styles | Sep 2008 | B2 |
| 7765222 | Styles et al. | Jul 2010 | B2 |
| 7769769 | Rasmussen | Aug 2010 | B2 |
| 7917463 | Dagum et al. | Mar 2011 | B2 |
| 20010037345 | Kiernan et al. | Nov 2001 | A1 |
| 20020059203 | Witkowski et al. | May 2002 | A1 |
| 20020087524 | Leathers | Jul 2002 | A1 |
| 20020107840 | Rishe | Aug 2002 | A1 |
| 20020188600 | Lindsay et al. | Dec 2002 | A1 |
| 20030066051 | Karr et al. | Apr 2003 | A1 |
| 20030088558 | Zaharioudakis et al. | May 2003 | A1 |
| 20030101169 | Bhatt et al. | May 2003 | A1 |
| 20030115194 | Pitts et al. | Jun 2003 | A1 |
| 20040133567 | Witkowski et al. | Jul 2004 | A1 |
| 20040181537 | Chawla et al. | Sep 2004 | A1 |
| 20050010569 | Styles | Jan 2005 | A1 |
| 20050010570 | Styles | Jan 2005 | A1 |
| 20050015369 | Styles et al. | Jan 2005 | A1 |
| 20050038782 | Styles et al. | Feb 2005 | A1 |
| Number | Date | Country |
|---|---|---|
| 1081611 | Mar 2001 | EP |
| WO 03012698 | Feb 2003 | WO |
| WO 03038662 | May 2003 | WO |
| Number | Date | Country | |
|---|---|---|---|
| 20090063441 A1 | Mar 2009 | US |
| Number | Date | Country | |
|---|---|---|---|
| Parent | 10856306 | May 2004 | US |
| Child | 12283194 | US |