Bi-gram Cardinality Estimation in Graph Database Query Planning
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing graph database query planning methods are inefficient in estimating cardinality for paths between nodes, leading to high computational costs and latency, especially in densely connected graphs, and struggle to maintain accurate estimates as the graph data mutates.
Innovation Solution
Implementing a query planner that uses bi-gram statistics and metadata, such as node and relationship counts, to estimate the cardinality of paths, allowing for the selection of the least expensive query plan and improving query execution efficiency.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Ease of manufacture
If traditional relational database query planning methods are used in graph databases, then implementation simplicity is maintained, but query execution efficiency deteriorates due to inaccurate cardinality estimation
Solution Approach 1:
The patent segments the graph database into bi-gram units (pairs of connected nodes and relationships) and maintains separate statistics for each bi-gram type. This segmentation allows the system to efficiently estimate cardinality for specific path patterns without analyzing the entire graph, resolving the contradiction by providing targeted statistical data that improves query planning accuracy while maintaining implementation simplicity through modular statistics collection.
2Measurement precision
If comprehensive graph analysis is performed for accurate cardinality estimation, then measurement precision improves, but computational cost and latency increase
Solution Approach 1:
The patent performs preliminary action by pre-computing and storing bi-gram statistics (node counts, relationship counts, and their products) during graph database operations. When query planning is needed, the system directly retrieves these pre-computed statistics rather than performing comprehensive graph analysis at query time. This resolves the contradiction by providing accurate cardinality estimates through readily available statistical data, eliminating the need for expensive real-time computations.
3Measurement precision
If detailed bi-gram statistics are collected for all node and relationship combinations, then cardinality estimation accuracy improves, but device complexity increases
Solution Approach 1:
The patent applies parameter changes by transforming the complex problem of estimating cardinality for arbitrary graph patterns into a simpler problem of retrieving and multiplying pre-stored bi-gram statistics. The system changes the approach from complex probabilistic modeling to straightforward statistical multiplication (bi-gram count × node count × relationship count), resolving the contradiction by maintaining high estimation accuracy while significantly reducing the complexity of the query planning mechanism.
4Loss of time
If query planning uses accurate cardinality estimates, then query execution time improves, but system complexity increases due to additional statistics maintenance
Solution Approach 1:
The patent implements self-service by integrating bi-gram statistics collection into the existing graph database operations. As nodes and relationships are added, modified, or deleted during normal database operations, the system automatically updates the corresponding bi-gram statistics without requiring separate maintenance processes. This resolves the contradiction by making the statistics maintenance transparent and automated, improving query execution time through accurate cardinality estimates while avoiding additional operational complexity.
Data Source
AI summary
A method and apparatus for estimating the cardinality of graph pattern queries using graph statistics and metadata is presented. In various embodiments, node and edge labels are used to compute estimates for graph patterns (bi-grams) and the estimates for these patterns as composed to provide cardinality estimates of longer paths. The computation of bi-grams is low cost and requires only minimal changes to the existing query planner in the existing database machinery to be useful. The resulting estimates are used during query execution to minimize the amount of work needed to complete a query and return a faithful and accurate answer to the user. The apparatus includes modules containing computer-executable instructions to perform the above method.


