System and method of query transformation
a query and transformation technology, applied in the field of data access middleware, can solve the problems of generating this type of sql more difficult, many database systems do not support this technology, and application servers cannot generally process queries as quickly
- Summary
- Abstract
- Description
- Claims
- Application Information
AI Technical Summary
Problems solved by technology
Method used
Image
Examples
example 1
In this example, a nested OLAP function appears in the operand of another OLAP function, so the query must be transformed.
Original Query
SELECT MAX( SUM( QTY ) OVER ( PARTITION BY SNO ))OVER ( )FROM SUPPLY
Transformed Query
SELECT MAX(C0) OVER ( )FROM ( SELECT SUM( QTY ) OVER ( PARTITION BY SNO ) C0 FROM SUPPLY ) T1
Explanation
Against Oracle, the original query will result in an error since the OLAP function MAX contains a nested SUM function in its operand. To eliminate the nesting, a derived table T1 is created, and the SUM function is pushed into the select list.
example 2
In this example, a nested OLAP function appears in the operand of an OLAP function. As well, the same nested OLAP function appears on its own in the select list. This query must be transformed.
Original Query
SELECT SNO, PNO, SUM( QTY ) OVER ( PARTITION BY SNO ), MAX( SUM( QTY ) OVER ( PARTITION BY SNO )) OVER ( )FROM SUPPLY
Transformed Query
SELECT C0, C1, C2, MAX( C2 ) OVER ( )FROM ( SELECT SNO C0, PNO C1, SUM( QTY ) OVER ( PARTITION BY SNO ) C2 FROM SUPPLY ) T1
Explanation
Against Oracle, the original query will result in an error since the OLAP function MAX contains a nested SUM function in its operand. To eliminate the nesting, a derived table T1 is created, and the SUM function is pushed into the select list. Note also that a small optimization is performed with respect to the. first OLAP function (SUM) in the select list of the original query, since it is identical to the operand of the MAX function. The SUM function only needs to be computed once.
example 3
In this example, a nested OLAP function appears in the operand of an OLAP function. As well, the nested OLAP function itself contains a nested OLAP function in its PARTITION BY clause. This query must be transformed.
Original Query
SELECT SNO, PNO, SUM( QTY ) OVER ( PARTITION BY AVG( QTY ) OVER ( PARTITION BY JNO )), MAX( SUM( QTY ) OVER ( PARTITION BY AVG( QTY ) OVER ( PARTITION BY JNO ))) OVER ( )FROM SUPPLY
Transformed Query
Pass 1SELECT C0, C1, C2, MAX( C2 ) OVER ( )FROM ( SELECT C0, C1, SUM( C2 ) OVER ( PARTITION BY AVG( QTY ) OVER ( PARTITION BY JNO ) ) C2 FROM SUPPLY ) T0Pass 2SELECT C0, C1, C2, MAX( C2 ) OVER ( )FROM ( SELECT C0, C1, SUM( C2 ) OVER ( PARTITION BY C3 ) C2 FROM ( SELECT SNO C0, PNO C1, QTY C2, AVG( QTY ) OVER ( PARTITION BY JNO ) C3 FROM SUPPLY ) T0 ) T1
Explanation
Against Oracle9i, the original query will result in an error since the OLAP functions SUM and MAX contain nested OLAP functions. This particular example requires 2 pa...
PUM
Abstract
Description
Claims
Application Information
- R&D Engineer
- R&D Manager
- IP Professional
- Industry Leading Data Capabilities
- Powerful AI technology
- Patent DNA Extraction
Browse by: Latest US Patents, China's latest patents, Technical Efficacy Thesaurus, Application Domain, Technology Topic, Popular Technical Reports.
© 2024 PatSnap. All rights reserved.Legal|Privacy policy|Modern Slavery Act Transparency Statement|Sitemap|About US| Contact US: help@patsnap.com