Method and system for limiting the cardinality of an SQL query result
First Claim
1. A method of generating a query execution plan in a computer with a memory responsive to a query including a specified size for a result of the query, comprising:
- generating a query execution plan in the memory of the computer; and
inserting at least one STOP operator in the query execution plan for limiting the size of the query result to no more than a specified cardinality.
1 Assignment
0 Petitions
Accused Products
Abstract
A STOP AFTER clause for a relational database management system (RDBMS) structured query language (SQL) causes the RDBMS, in response to a query, to return a query result having at most a predetermined cardinality specified in the query. A query with a STOP AFTER clause is processed by the RDBMS by provision of one or more STOP operators that are inserted into a query execution plan generated by the RDBMS to execute the query. In a conservative policy, STOP operators are inserted in the query execution plan such that no tuples that might be required in the query result are discarded. In contrast, an aggressive policy inserts a STOP operator in the query execution plan wherever it is able to provide a beneficial cardinality reduction. A RESTART operator is inserted into aggressive policy query execution plans to ensure that at least the predetermined number of tuples are returned in the query result, and a final STOP operator is added at or near the root of the plan to ensure that at most the specified number of tuples are produced.
-
Citations
25 Claims
-
1. A method of generating a query execution plan in a computer with a memory responsive to a query including a specified size for a result of the query, comprising:
-
generating a query execution plan in the memory of the computer; and inserting at least one STOP operator in the query execution plan for limiting the size of the query result to no more than a specified cardinality. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8)
-
-
9. A method executable by a computer for limiting the size of a query result in a database management system in response to a query, comprising:
-
receiving a query in the memory of the computer; examining the query to determine whether the query includes a requirement for a size of a result of the query; generating at least one query execution plan in response to the query; and
;inserting at least one STOP operator in the query execution plan for limiting a number of tuples in the result to a cardinality number corresponding to a required size of the result. - View Dependent Claims (10, 11, 12, 13, 14, 15)
-
-
16. A computer program device comprising:
-
a computer program storage device readable by a digital processing apparatus; and a program means on the program storage device and including instructions for causing the digital processing apparatus to limit the number of tuples returned by a database management system in a query result, by; receiving a query including specification of a result cardinality; generating a query execution plan in response to the query, the query execution plan having predicates for executing the query; and placing an operator in the query execution plan to limit a number of tuples returned in the query result to no more than the result cardinality. - View Dependent Claims (17, 18, 19, 20, 21, 22)
-
-
23. A method for querying a database using a database management system, the method executable on a computer with a memory and including:
-
receiving in the memory of the computer a query that includes a clause limiting the size of a query result to N; executing the query to produce a result set of tuples that satisfy the query; during execution of the query, limiting the number of tuples in the result set to no more than N; and returning the result set to a user. - View Dependent Claims (24, 25)
-
Specification