Subquery Domain Constraints for Smaller Intermediate Result Sets
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Relational database systems face inefficiencies in query execution due to the generation of large intermediate result sets, especially when only a small subset is needed for further processing, leading to increased memory and processor usage.
Innovation Solution
The database engine incorporates a domain constraint optimizer that inserts domain constraints into subqueries based on estimated cardinality and filter conditions, reducing unnecessary row retrieval by using early-probe operators and hash tables to filter out superfluous data early in the operator tree.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If the database engine executes subqueries without domain constraints, then complete intermediate result sets are generated, but memory usage and processing time increase significantly
Solution Approach 1:
The optimizer performs preliminary analysis of the query plan to identify domain constraints from outer queries before executing the subquery. By pushing these constraints down into the subquery execution, the system preliminarily filters the data scope, reducing the intermediate result set size before it grows large
Solution Approach 2:
The optimizer extracts unnecessary data from the intermediate result set by applying domain constraints that identify and remove rows that will not be needed for the final query result. This extraction happens early in the execution plan, preventing wasted processing on irrelevant data
2Reliability
If the database engine retrieves all rows from subqueries, then data completeness is ensured, but memory consumption increases
Solution Approach 1:
The system performs preliminary identification of domain constraints from outer queries and pushes them into the subquery execution plan. This preliminary action ensures that only relevant rows are retrieved, maintaining data completeness for the final result while reducing memory consumption by excluding unnecessary rows from the outset
3Quantity of substance
If domain constraints are inserted into subqueries, then intermediate result set size is reduced, but query plan complexity increases
Solution Approach 1:
The query optimizer automatically performs the analysis and transformation of pushing domain constraints into subqueries without requiring manual intervention. The system self-services by identifying optimization opportunities and applying the necessary plan modifications, making the complexity management transparent to the user while still achieving reduced intermediate result sets
Data Source
AI summary
A database engine receives a human-readable database query that includes a subquery, and parses the database query to build an operator tree. The operator tree includes a subtree corresponding to the subquery. The database engine estimates the number of rows that will accessed when the subtree is executed and estimates the fraction of the cardinality of rows that will be filtered out by subsequent operations in the operator tree. In accordance with a determination that the estimated fraction exceeds a first threshold, the database engine inserts a domain constraint into the subtree that restricts rows retrieved by execution of the subtree, thereby forming a modified operator tree. The database engine executes the modified operator tree to form a final result set corresponding to the database query and returns the final result set.


