IP Library Granted Patent US 11,176,138
Granted Patent B2
US 11,176,138 · App. 16/800,837 · Granted Nov 16, 2021

Caching techniques for query runtime state

Inventors: Punit B. Shah (Castro Valley, CA); Douglas Doole (Livermore, CA); Rama K Korlapati (El Segundo, CA); Serge P. Rielau (Alamo, CA)
Assignee: salesforce.com, inc.
G06F16/24549G06F16/24539G06F16/24544
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 11,176,138
App. No.
16/800,837
Granted
Nov 16, 2021
Kind
B2
Abstract

Caching runtime plan data that is determined not to change for different invocations of a query plan. In some embodiments, a computing system accesses information that specifies a query plan generated for a first database query and generates a first runtime plan for the first database query based on the query plan. In some embodiments, the system caches information generated for the first runtime plan that is determined not to change for different invocations of the query plan. For example, transformation code may include separate functions for mutable and immutable state. In some embodiments, the system retrieves and uses the cached information to generate a second runtime plan for a second database query. Disclosed techniques may improve performance of query plan transformations that hit in the runtime plan cache.

Claims (60)

1. A method, comprising:

accessing, by a computing system, information that specifies a query plan generated for a first database query;

generating, by the computing system based on the query plan, a first runtime plan for the first database query, wherein:

the query plan has a tree structure and the first runtime plan has a corresponding tree structure;

two or more different nodes in the query plan tree structure specify respective operations of the query plan; and

two or more different nodes of the first runtime plan specify respective state for a corresponding node in the tree structure of the query plan;

linearizing information of the tree structure of the first runtime plan for caching, including:

storing nodes of the first runtime plan at memory offsets according to a traversal of the tree structure of the first runtime plan; and

generating metadata that indicates relative memory locations of multiple data elements associated with nodes of the tree structure of the first runtime plan;

caching, by the computing system, the linearized information of the first runtime plan, wherein the cached information is determined not to change for different invocations of the query plan; and

retrieving and using, by the computing system, the cached information to generate a second runtime plan for a second database query.

2. The method of claim 1 , wherein the cached information includes one or more of:

a description of a tuple schema;

a join method;

a join order;

one or more predicates; or

one or more expressions.

3. The method of claim 1 , wherein the generating includes acquiring a lock and allocating working memory and wherein results of the acquiring and allocating are not cached and the results differ for the different invocations of the query plan.

4. The method of claim 1 , wherein the retrieving the cached information includes converting relative addresses in the metadata to pointers.

5. The method of claim 1 , wherein the retrieving is performing in response to a cache hit that is detected based on a hash of the second database query and database context information associated with the second database query.

6. The method of claim 1 , further comprising:

performing one or more transformation operations to generate runtime state information for the second runtime plan that are allowed to differ for the different invocations of the query plan.

7. A non-transitory computer-readable medium having instructions stored thereon that are executable by a computing device to perform operations comprising:

accessing information that specifies a query plan generated for a first database query;

generating, based on the query plan, a first runtime plan for the first database query, wherein:

the query plan has a tree structure and the first runtime plan has a corresponding tree structure;

two or more different nodes in the query plan tree structure specify respective operations of the query plan; and

two or more different nodes of the first runtime plan specify respective state for a corresponding node in the tree structure of the query plan;

linearizing information of the tree structure of the first runtime plan for caching, including:

storing nodes of the first runtime plan at memory offsets according to a traversal of the tree structure of the first runtime plan; and

generating metadata that indicates relative memory locations of multiple data elements associated with nodes of the tree structure of the first runtime plan;

caching the linearized information of the first runtime plan, wherein the cached information is determined not to change for different invocations of the query plan; and

retrieving and using the cached information to generate a second runtime plan for a second database query.

8. The non-transitory computer-readable medium of claim 7 , wherein the cached information includes one or more of:

a description of a tuple schema;

a join method;

a join order;

one or more predicates; or

one or more expressions.

9. The non-transitory computer-readable medium of claim 7 , wherein the generating includes acquiring a lock and allocating working memory and wherein results of the acquiring and allocating are not cached and the results differ for the different invocations of the query plan.

10. The non-transitory computer-readable medium of claim 7 , wherein the retrieving is performing in response to a cache hit that is detected based on a hash of the second database query and database context information associated with the second database query.

11. A system, comprising:

one or more processors configured to:

access information that specifies a query plan generated for a first database query;

generate, based on the query plan, a first runtime plan for the first database query, wherein:

the query plan has a tree structure and the first runtime plan has a corresponding tree structure;

two or more different nodes in the query plan tree structure specify respective operations of the query plan; and

two or more different nodes of the first runtime plan specify respective state for a corresponding node in the tree structure of the query plan;

linearize information of the tree structure of the first runtime plan for caching, including to:

store nodes of the first runtime plan at memory offsets according to a traversal of the tree structure of the first runtime plan; and

generate metadata that indicates relative memory locations of multiple data elements associated with nodes of the tree structure of the first runtime plan;

cache the linearized information of the first runtime plan, wherein the cached information is determined not to change for different invocations of the query plan; and

retrieve and using the cached information to generate a second runtime plan for a second database query.

12. The system of claim 11 , wherein the cached information includes one or more of:

a description of a tuple schema;

a join method;

a join order;

one or more predicates; or

one or more expressions.

13. The system of claim 11 , wherein the one or more processors are configured to retrieve the cached information in response to a cache hit that is detected based on a hash of the second database query and database context information associated with the second database query.

Assignments (2)
CHANGE OF NAME Recorded Dec 18, 2024
From: SALESFORCE.COM, INC.
To: SALESFORCE, INC.
Reel/Frame 069717/0480 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Feb 25, 2020
From: SHAH, PUNIT B.; DOOLE, DOUGLAS; KORLAPATI, RAMA K.; RIELAU, SERGE P.
To: SALESFORCE.COM, INC.
Reel/Frame 051924/0953 →
Continuity (1)
Related Publication 20210263936A1 · Aug 26, 2021
Cited By (1)
US 12,405,927