CPC G06F 16/24542 (2019.01) [G06F 11/3409 (2013.01); G06F 16/24537 (2019.01)] | 20 Claims |
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.
|