IP Library Granted Patent US 12,135,713
Granted Patent B2
US 12,135,713 · App. 17/985,294 · Granted Nov 5, 2024

Efficiently accessing shared operators in database query plans

Inventor: Yinghua Ouyang (Xi'an, CN)
Assignee: SAP SE
G06F16/24542G06F11/3409G06F16/24537
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 12,135,713
App. No.
17/985,294
Granted
Nov 5, 2024
Kind
B2
Abstract

The present disclosure involves systems, software, and computer implemented methods for efficiently accessing shared operators in database query plans. One example method includes identifying a query plan tree that represents a query plan for a database query. A node identifier of each node of the query plan tree is initialized to a default node identifier value and a global node identifier counter for the query plan tree is initialized. The query plan tree is traversed including determining whether a node identifier of a current node equals the default node identifier value. If the node identifier of the current node equals the default node identifier value, the current node is processed, the node identifier of the current node is set to a current value of the global node identifier counter, and the global node identifier counter is incremented. Otherwise processing of the current node is skipped.

Claims (67)

1. A computer-implemented method comprising:

receiving, at a database system, a database query that queries at least one database artifact stored in the database system;

generating, by a query plan generator of the database system, a query plan tree that represents a query plan for the database query;

initializing, by a query engine of the database system and in memory of the database system, a respective node identifier of each node of the query plan tree to a default node identifier value;

initializing, by the query engine of the database system and in the memory of the database system, a global node identifier counter for the query plan tree; and

traversing, by the query engine of the database system, the query plan tree, wherein the traversing includes:

determining, by the query engine of the database system, whether a node identifier of a current node equals the default node identifier value;

in response to determining that the node identifier of the current node equals the default node identifier value:

processing, by the query engine of the database system, the current node;

setting, by the query engine of the database system and in the memory of the database system, the node identifier of the current node to a current value of the global node identifier counter for the query plan tree; and

incrementing, by the query engine of the database system and in the memory of the database system, the global node identifier counter for the query plan tree;

in response to determining that the node identifier of the current node does not equal the default node identifier value, skipping, by the query engine of the database system, processing of the current node;

determining, by the query engine of the database system, whether the current node has any unvisited child nodes;

traversing, by the query engine of the database system, to a next child node of the current node in response to determining that the current node has at least one unvisited child node;

determining, by the query engine of the database system, whether all nodes of the query plan tree have been traversed; and

traversing, by the query engine of the database system, to a next node of the query plan tree in response to determining that at least one node of the query plan tree has not been traversed.

2. The computer-implemented method of claim 1 , wherein nodes of the query plan tree represent operators to be processed during execution of the query plan.

3. The computer-implemented method of claim 2 , wherein determining that the node identifier of the current node equals the default node identifier value comprises determining that an operator represented by the current node has not yet been processed.

4. The computer-implemented method of claim 2 , wherein determining that the node identifier of the current node does not equal the default node identifier value comprises determining that an operator represented by the current node has already been processed.

5. The computer-implemented method of claim 2 , wherein determining that the node identifier of the current node does not equal the default node identifier value comprises determining that the current node has multiple parent nodes and has already been visited based on processing of one of the parent nodes.

6. The computer-implemented method of claim 1 , wherein the query plan tree is a directed acrylic graph.

7. The computer-implemented method of claim 1 , wherein different global node identifier counters are used for different query plan trees.

8. A system comprising:

one or more computers; and

a non-transitory computer-readable medium coupled to the one or more computers having instructions stored thereon which, when executed by the one or more computers, cause the one or more computers to perform operations comprising:

receiving, at a database system, a database query that queries at least one database artifact stored in the database system;

generating, by a query plan generator of the database system, a query plan tree that represents a query plan for the database query;

initializing, by a query engine of the database system and in memory of the database system, a respective node identifier of each node of the query plan tree to a default node identifier value;

initializing, by the query engine of the database system and in the memory of the database system, a global node identifier counter for the query plan tree; and

traversing, by the query engine of the database system, the query plan tree, wherein the traversing includes:

determining, by the query engine of the database system, whether a node identifier of a current node equals the default node identifier value;

in response to determining that the node identifier of the current node equals the default node identifier value:

processing, by the query engine of the database system, the current node;

setting, by the query engine of the database system and in the memory of the database system, the node identifier of the current node to a current value of the global node identifier counter for the query plan tree; and

incrementing, by the query engine of the database system and in the memory of the database system, the global node identifier counter for the query plan tree;

in response to determining that the node identifier of the current node does not equal the default node identifier value, skipping, by the query engine of the database system, processing of the current node;

determining, by the query engine of the database system, whether the current node has any unvisited child nodes;

traversing, by the query engine of the database system, to a next child node of the current node in response to determining that the current node has at least one unvisited child node;

determining, by the query engine of the database system, whether all nodes of the query plan tree have been traversed; and

traversing, by the query engine of the database system, to a next node of the query plan tree in response to determining that at least one node of the query plan tree has not been traversed.

9. The system of claim 8 , wherein nodes of the query plan tree represent operators to be processed during execution of the query plan.

10. The system of claim 9 , wherein determining that the node identifier of the current node equals the default node identifier value comprises determining that an operator represented by the current node has not yet been processed.

11. The system of claim 9 , wherein determining that the node identifier of the current node does not equal the default node identifier value comprises determining that an operator represented by the current node has already been processed.

12. The system of claim 9 , wherein determining that the node identifier of the current node does not equal the default node identifier value comprises determining that the current node has multiple parent nodes and has already been visited based on processing of one of the parent nodes.

13. The system of claim 8 , wherein the query plan tree is a directed acrylic graph.

14. The system of claim 8 , wherein different global node identifier counters are used for different query plan trees.

15. A computer program product encoded on a non-transitory storage medium, the product comprising non-transitory, computer readable instructions for causing one or more processors to perform operations comprising:

receiving, at a database system, a database query that queries at least one database artifact stored in the database system;

generating, by a query plan generator of the database system, a query plan tree that represents a query plan for the database query;

initializing, by a query engine of the database system and in memory of the database system, a respective node identifier of each node of the query plan tree to a default node identifier value;

initializing, by the query engine of the database system and in the memory of the database system, a global node identifier counter for the query plan tree; and

traversing, by the query engine of the database system, the query plan tree, wherein the traversing includes:

determining, by the query engine of the database system, whether a node identifier of a current node equals the default node identifier value;

in response to determining that the node identifier of the current node equals the default node identifier value:

processing, by the query engine of the database system, the current node;

setting, by the query engine of the database system and in the memory of the database system, the node identifier of the current node to a current value of the global node identifier counter for the query plan tree; and

incrementing, by the query engine of the database system and in the memory of the database system, the global node identifier counter for the query plan tree;

in response to determining that the node identifier of the current node does not equal the default node identifier value, skipping, by the query engine of the database system, processing of the current node;

determining, by the query engine of the database system, whether the current node has any unvisited child nodes;

traversing, by the query engine of the database system, to a next child node of the current node in response to determining that the current node has at least one unvisited child node;

determining, by the query engine of the database system, whether all nodes of the query plan tree have been traversed; and

traversing, by the query engine of the database system, to a next node of the query plan tree in response to determining that at least one node of the query plan tree has not been traversed.

16. The computer program product of claim 15 , wherein nodes of the query plan tree represent operators to be processed during execution of the query plan.

17. The computer program product of claim 16 , wherein determining that the node identifier of the current node equals the default node identifier value comprises determining that an operator represented by the current node has not yet been processed.

18. The computer program product of claim 16 , wherein determining that the node identifier of the current node does not equal the default node identifier value comprises determining that an operator represented by the current node has already been processed.

19. The computer program product of claim 16 , wherein determining that the node identifier of the current node does not equal the default node identifier value comprises determining that the current node has multiple parent nodes and has already been visited based on processing of one of the parent nodes.

20. The computer program product of claim 15 , wherein the query plan tree is a directed acrylic graph.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Nov 11, 2022
From: OUYANG, YINGHUA
To: SAP SE
Reel/Frame 061734/0698 →
Continuity (1)
Related Publication 20240160627A1 · May 16, 2024
Cited By (1)
US 12,346,472