Database Query Optimization via Join Inversion
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Relational databases face inefficiencies in processing left outer join commands, which can lead to suboptimal query performance due to the large cardinality of one table compared to the other.
Innovation Solution
Optimizing database queries by replacing left outer join commands with inner join commands, specifically by inverting the loop evaluation order and using the right-hand side as the outer loop, and transforming IN expressions into join and Boolean expressions based on conjunct position analysis in abstract syntax trees.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If left outer join commands are used to combine tables without requiring matching records, then all records from both tables are preserved in the result, but query processing efficiency deteriorates due to large cardinality differences between tables
Solution Approach 1:
The patent inverts the traditional left outer join approach by using right outer join instead. This inversion changes which table is treated as the driving table, allowing the query to start from the smaller table (right table) and join to the larger table (left table), thereby improving efficiency while preserving result completeness through the use of NULL coalescence operations to maintain all records from both tables
2Ease of manufacture
If loop evaluation order in join operations is not optimized, then implementation simplicity is maintained, but computational load increases due to processing large cardinality tables first
Solution Approach 1:
The patent applies preliminary action by first determining the cardinality of both tables before executing the join operation. Based on this preliminary assessment, the system dynamically selects the optimal evaluation order, starting with the table that has fewer records. This preliminary planning step ensures that the join operation processes the smaller table first, reducing the overall computational load while maintaining clear and structured implementation
Data Source
AI summary
A method and system of transforming a query at a web server are provided. An abstract syntax tree representing the query can be traversed from the top down, for each node in the abstract syntax tree: labeling the node as being in a conjunct position when the node's parent is a WHERE node; labeling the node as being not in a conjunct position when the node's parent is an OR node; and labeling the node identically to the node's parent node when the node's parent is an AND node. Then any IN node in the abstract syntax tree can be transformed to an INNER JOIN node when the IN node is labeled as being in a conjunct position. The abstract syntax tree can be converted into a Structured Query Language (SQL) query, which can then be passed to a database for processing.


