Hierarchical Database Query Processing With Parallel Worker Threads
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing hierarchical query requests in database tables with hierarchical relationships are inefficient and time-consuming due to the serial processing of data to find child nodes, leading to prolonged processing times.
Innovation Solution
A hierarchical query method that groups service data in a database table into multiple worker threads based on connection conditions, allowing parallel processing to quickly identify child nodes in a tree structure, reducing processing time and improving efficiency.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If serial processing is used to query child nodes in a hierarchical database table, then the query process is simple to implement, but the processing time is prolonged and efficiency is low
Solution Approach 1:
The patent segments the database table data into multiple groups based on the connection condition (e.g., grouping by parent node identifiers). Each group is assigned to a separate worker thread for parallel processing. This segmentation enables concurrent execution of queries across different data subsets, significantly reducing the overall processing time while maintaining correctness through proper grouping logic.
2Productivity
If parallel processing with multiple worker threads is used to query hierarchical data, then processing efficiency is improved, but the system complexity increases
Solution Approach 1:
The patent divides the data and processing tasks into segments handled by multiple worker threads, each independently querying its assigned data group. This segmentation approach enables parallel processing while keeping each thread's logic relatively simple.
Solution Approach 2:
The patent merges the results from multiple worker threads to construct the final hierarchical query result. The coordinator thread collects and combines the partial results from all worker threads, integrating them into a complete tree structure. This merging approach allows parallel execution while maintaining a unified output, effectively managing system complexity.
3Speed
If data is grouped into multiple worker threads for parallel querying, then child nodes are identified faster, but the complexity of data grouping and thread coordination increases
Solution Approach 1:
The patent performs preliminary grouping of data by parent node identifiers before the actual query execution. This pre-grouping organizes the data into structures that can be efficiently distributed to worker threads, avoiding the need for complex runtime grouping logic. The connection condition is evaluated in advance to create the initial data groups.
Solution Approach 2:
The patent segments data into groups based on connection conditions (e.g., grouping child records by their parent identifiers). Each segment is assigned to a specific worker thread, enabling parallel processing while maintaining logical organization. This segmentation reduces the complexity of thread coordination by creating clear, non-overlapping data boundaries.
Data Source
AI summary
A method is provided to process a hierarchical query request for requesting to query a target database table, where the hierarchical query request includes a query start condition and a connection condition. The method includes: in a first query round, first data is queried from the target database table based on the query start condition, and the first data is used as a root node of a tree structure; a plurality of pieces of service data in the target database table are grouped into N data groups corresponding to N worker threads based on the connection condition, where N is an integer greater than 1; and in an ith query round greater than 1, a leaf node in the current tree structure is selected as a parent node; and a target worker thread corresponding to the parent node is determined from the N worker threads based on the connection condition.


