Method and system for optimizing queries in a multi-tenant database environment
First Claim
1. A non-transitory computer readable medium having stored thereon instructions that, when executed, are configurable to cause one or more processors to:
- receive a user database query in a structured query language with the one or more processors;
parse the user database query and automatically generate, with the one or more processors, a set of parallel database sub queries that in combination are equivalent to the user database query in results that are expected to be returned, wherein individual database sub queries in the set of parallel database sub queries are compared against other optimizable filters against the user database query;
perform one or more runtime prequeries to gather optimization information for a selected tenant of a multitenant environment corresponding to the user database query;
optimize each database sub query based on the lowest calculated cost of data access, wherein each database sub query is fully optimized utilizing a database query optimizer;
execute, with the one or more processors, the set of parallel database sub queries against multiple database tables, if a cost of data access of the user database query is expected to be more than a cost of data access of a new database query formed by combining the returned results of the set of parallel database sub queries, the forming of the new database query being accomplished by at least forming a clause that combines the set of parallel database sub queries into a database query equivalent to the user database query; and
return, with the one or more processors, results of the new database query.
1 Assignment
0 Petitions
Accused Products
Abstract
In accordance with embodiments, there are provided mechanisms and methods for query optimization in a database system. These mechanisms and methods for query optimization in a database system can enable embodiments to optimize OR expression filters referencing different logical tables. The ability of embodiments to optimize OR expression filters referencing different logical tables can enable optimization that is dynamic and specific to the particular tenant for whom the query is run and improve the performance and efficiency of the database system in response to query requests.
197 Citations
20 Claims
-
1. A non-transitory computer readable medium having stored thereon instructions that, when executed, are configurable to cause one or more processors to:
-
receive a user database query in a structured query language with the one or more processors; parse the user database query and automatically generate, with the one or more processors, a set of parallel database sub queries that in combination are equivalent to the user database query in results that are expected to be returned, wherein individual database sub queries in the set of parallel database sub queries are compared against other optimizable filters against the user database query; perform one or more runtime prequeries to gather optimization information for a selected tenant of a multitenant environment corresponding to the user database query; optimize each database sub query based on the lowest calculated cost of data access, wherein each database sub query is fully optimized utilizing a database query optimizer; execute, with the one or more processors, the set of parallel database sub queries against multiple database tables, if a cost of data access of the user database query is expected to be more than a cost of data access of a new database query formed by combining the returned results of the set of parallel database sub queries, the forming of the new database query being accomplished by at least forming a clause that combines the set of parallel database sub queries into a database query equivalent to the user database query; and return, with the one or more processors, results of the new database query. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)
-
-
15. A method comprising:
-
receive a user database query in a structured query language with the one or more processors; the processor system parsing the user database query and automatically generate a set of parallel database sub queries that in combination are equivalent to the user database query in results that are expected to be returned, wherein individual database sub queries in the set of parallel database sub queries are compared against other optimizable filters against the user database query; the processor system performing one or more runtime prequeries to gather optimization information for a selected tenant of a multitenant environment corresponding to the user database query; the processor system optimizing each database sub query based on the lowest calculated cost of data access, wherein each database sub query is fully optimized utilizing a database query optimizer; the processor system executing the set of parallel database sub queries against multiple database tables, if a cost of data access of the user database query is expected to be more than a cost of data access of a new database query formed by combining the returned results of the set of parallel database sub queries, the forming of the new database query being accomplished by at least forming a clause that combines the set of parallel database sub queries into a database query equivalent to the user database query; and the processor system returning results of the new database query. - View Dependent Claims (17, 19, 20)
-
-
16. A system having one or more hardware computing devices, each having one or more processors and associated memory, configurable for optimizing queries in a database system, the system comprising:
-
a memory system including a machine readable medium having stored thereon one or more sequences of instructions which, when executed, cause a method to be carried out, the method including at least receiving a database user query at the computer system; the system parsing the user database query and automatically generating a set of parallel database sub queries that in combination are equivalent to the user database query in results that are expected to be returned, wherein the individual database sub queries in the set of parallel database sub queries are compared against other optimizable filters against the user database query; the system performing one or more runtime prequeries to gather optimization information for a selected tenant of a multitenant environment corresponding to the user database query; the system optimizing each database sub query based on the lowest calculated cost of data access, wherein each database sub query is fully optimized utilizing a query optimizer; the system forming a database query that is applied to multiple database tables, if a cost of data access of the user database query is expected to be more than the database query formed, optimizing each database subquery based on the lowest calculated cost of data access, the forming of the database query being by at least forming a clause that combines the set of parallel database subqueries into a database query equivalent to the user database query. - View Dependent Claims (18)
-
Specification