Multi-step Query Plan Operator for Graph Database Execution
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Relational database systems face challenges in efficiently executing graph queries, particularly for shortest path queries, due to the need for recursive joins and custom conditional logic, which can lead to performance issues and error-prone code.
Innovation Solution
The implementation of a multi-step sequence query plan operator in a relational database system, which generates a query plan with an initial step, intermediate steps, and a final step, allowing for recursive operations and early termination conditions, thereby improving the execution of graph queries.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Adaptability or versatility
If recursive joins and custom conditional logic are used to execute graph queries in relational database systems, then graph query capability is achieved, but execution performance deteriorates and code becomes error-prone
Solution Approach 1:
The query execution process is segmented into distinct steps: graph query translation step, query plan generation step, and query execution step. The query plan itself is segmented into multiple phases including graph traversal phase, path evaluation phase, and result aggregation phase. This segmentation allows each phase to be optimized independently, improving overall execution performance while maintaining graph query capability.
Solution Approach 2:
An intermediary query plan structure is introduced between the graph query language and the relational database execution engine. This query plan acts as a mediator that translates graph query concepts into optimized relational operations, enabling efficient execution without requiring custom conditional logic in the application layer.
2Adaptability or versatility
If custom conditional logic is written to handle graph queries, then query flexibility is achieved, but code complexity increases and errors increase
Solution Approach 1:
The system performs self-service by automatically generating optimized query plans from high-level graph queries. The query plan generator autonomously translates graph query concepts into execution steps, eliminating the need for developers to write custom conditional logic. This maintains query flexibility while significantly reducing code complexity.
Solution Approach 2:
The system changes parameters from custom code-based query execution to parameterized query plan execution. Instead of writing conditional logic, users specify query parameters (start nodes, end nodes, path constraints), and the system automatically generates the execution plan. This parameterization approach maintains flexibility while reducing complexity.
3Adaptability or versatility
If recursive common table expressions are used to handle graph queries, then recursive query capability is achieved, but performance deteriorates
Solution Approach 1:
The system performs preliminary action by pre-computing and caching graph traversal results during the query plan generation phase. The query plan generator analyzes the graph structure and pre-determines optimal traversal paths, which are then executed efficiently during query execution. This preliminary preparation eliminates the need for slow runtime recursive CTE operations.
Solution Approach 2:
The system replaces the mechanical recursive CTE mechanism with a more efficient query plan execution mechanism. Instead of using recursive SQL statements that process rows one by one, the system uses a phased execution approach with batch processing, significantly improving performance while maintaining recursive query capability.
4Adaptability or versatility
If recursive joins are used to perform shortest path queries, then graph traversal is achieved, but execution time increases
Solution Approach 1:
The query execution uses periodic action by processing graph traversal in distinct phases: initialization phase, traversal phase, and termination phase. The traversal phase executes in iterative cycles where each cycle processes a specific depth level of the graph, rather than using continuous recursive joins. This periodic processing reduces execution time while maintaining complete graph traversal capability.
Solution Approach 2:
The system skips unnecessary join operations by using a phased execution approach. Instead of performing multiple sequential joins for each path level, the system pre-computes path candidates and then filters them in a single efficient operation, rushing through the execution process and reducing overall execution time.
Data Source
AI summary
Methods, systems, and computer program products are provided that construct and execute multi-step query plans in a database application. A database application accepts a query such as, for example, a graph query. The database application generates a physical query plan comprising a set of execution steps that perform the query. The set of execution steps comprises at least an initial step, an intermediate step and a final step. The database executes the query by passing control to the initial step that, when complete, passes execution control to some other step. The intermediate step executes and when complete, may pass execution control to any other step including itself. Steps may be configured to communicate arbitrary data between steps. The generated query plan may also comprise multiple multi-step sequences, and such sequences may be configured to execute in the alternative based on intermediate query results, or a parameter included in the query.


