CN-122019586-A - Graph database query method, electronic equipment and storage medium
Abstract
The application discloses a graph database query method, electronic equipment and a storage medium, wherein the method comprises the steps of dividing query sentences into multiple stages of deep query conditions; the method comprises the steps of obtaining limiting parameters based on multi-level deep query conditions, determining the number of query limits corresponding to each level of deep query based on the limiting parameters, carrying out multi-level deep query on an attribute graph by utilizing the multi-level deep query conditions and the number of query limits corresponding to each level of deep query to obtain target query results, wherein the second number of the query results obtained by each level of deep query is not larger than the number of query limits corresponding to corresponding levels, storing the attribute graph in a graph database, updating the number of query limits corresponding to at least one level of deep query in response to the target query results not meeting preset conditions, and continuing to carry out deep query according to the updated number of query limits until the target query results meet the preset conditions. Through the mode, the query efficiency can be improved while a large number of redundant queries are not ensured.
Inventors
- YU YI
- ZHOU MINGWEI
- ZHU LINHAO
- YANG FUXING
- DENG ZHIGUO
- REN ZHIHONG
- SHAN JIANAN
Assignees
- 浙江大华技术股份有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20251216
Claims (10)
- 1. A graph database query method, comprising: dividing the query statement into multiple levels of deep query conditions; acquiring a limiting parameter based on the multi-stage depth query condition; determining the query limit number corresponding to each level of depth query based on the limit parameters; Performing multi-level deep query on an attribute map by using the multi-level deep query condition and the query limit number corresponding to each level of deep query to obtain target query results, wherein the second number of the query results obtained by each level of deep query is not more than the query limit number corresponding to the corresponding level, and the attribute map is stored in a map database; And updating the query limit number corresponding to the at least one-level deep query in response to the target query result not meeting the preset condition, and continuing the deep query according to the updated query limit number until the target query result meets the preset condition.
- 2. The method of claim 1, wherein updating the number of query restrictions corresponding to the at least one level of deep queries and continuing the deep queries according to the updated number of query restrictions comprises: Taking the last stage of the multi-stage deep query as the current stage, judging whether a query result obtained by the current stage deep query comprises all nodes belonging to the current stage in the attribute graph, if not, updating the query limit number corresponding to the current stage, and querying the current stage non-queried nodes based on the updated query limit number corresponding to the current stage and the current stage deep query condition to obtain an updated target query result; Responding to the updated target query result not meeting the preset condition, and the current level has no queried nodes, and executing the query limit number corresponding to the current level and the subsequent steps again until all nodes of the current level are queried or the updated target query result meets the preset condition; Responding to the updated target query result not meeting the preset condition, and the current level does not have any non-queried node, taking the previous level of the current level as a new current level, and re-executing the query result obtained by judging the depth query of the current level to judge whether the query result comprises all nodes of the current level and the subsequent steps until the target query result meets the preset condition; And stopping inquiring and returning the updated target inquiring result in response to the updated target inquiring result meeting the preset condition.
- 3. The method of claim 1 or 2, wherein the preset condition comprises the target query result satisfying the query statement or the target query result satisfying the query statement and the number of target query results being greater than a threshold.
- 4. The method of claim 1, wherein the multi-level deep queries include a first-level deep query and a non-first-level deep query, and wherein the at least one-level deep query requiring updating of the query limit number includes at least one-level non-first-level deep query; And/or, the updating of the number of query restrictions comprises expanding the number of query restrictions.
- 5. The method of claim 1, wherein determining a number of query restrictions corresponding to each level of depth query based on the restriction parameters comprises: Judging whether the limiting parameter is larger than a preset parameter or not; Setting the limit quantity of each query as the quantity of returned results in response to the limit parameter not being greater than a preset parameter, wherein the quantity of returned results is obtained based on the query statement; and setting each inquiry limit number to be a preset multiple of the product of the returned result number and the limit parameter in response to the limit parameter being larger than a preset parameter.
- 6. The method of claim 1, wherein the multi-level deep query conditions include a first-level deep query condition and a non-first-level deep query condition; The depth of the node or the edge in the query range corresponding to the first-level depth query condition in the attribute graph is smaller than the depth of the node or the edge in the query range corresponding to the non-first-level depth query condition in the attribute graph; and/or the number of query restrictions corresponding to the first-level deep queries is greater than the number of query restrictions corresponding to the non-first-level deep queries.
- 7. The method of claim 1, wherein the obtaining limiting parameters based on the multi-level depth query condition comprises: judging whether the non-first-stage deep query condition in the multi-stage deep query conditions comprises a screening condition or not; And counting the number of the non-first-stage deep query conditions containing the screening conditions to obtain the limiting parameters.
- 8. The method of claim 1, wherein performing the multi-level deep query on the attribute map using the multi-level deep query condition and the number of query restrictions corresponding to each level of deep query to obtain the target query result comprises: When each level of deep query is performed, obtaining an association relation of query results based on the previous level of deep query, obtaining all nodes meeting the query limit number corresponding to the current level of deep query, and filtering all nodes by utilizing the current level of deep query conditions to obtain the query results of the current level of deep query; and obtaining the target query result based on the query result of the last-stage deep query.
- 9. An electronic device comprising a memory having stored therein program instructions and a processor for executing the program instructions to implement the method of any one of claims 1 to 8.
- 10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores program instructions, the program instructions being executable by a processor to implement the method of any one of claims 1 to 8.
Description
Graph database query method, electronic equipment and storage medium Technical Field The present application relates to the field of graph databases, and in particular, to a graph database query method, an electronic device, and a storage medium. Background The graph is composed of two elements, nodes and edges. Each node represents an entity and each edge represents a relationship between two nodes connected. The current graph database generally adopts a mode of acquiring data records from the bottom database one by one and storing the data records in the memory to judge the data records in the memory to finish the query, but if the number of the data records in the query range is too large, the data records meeting the condition can not be found in one query, the query operation of the data records needs to be circulated for many times on the bottom database, so that the query performance is poor. Disclosure of Invention The application mainly solves the technical problem of providing a graph database query method, electronic equipment and a storage medium, which can improve query efficiency while ensuring that a large number of redundant queries do not occur. In order to solve the technical problems, the first aspect of the application provides a graph database query method, which comprises the steps of dividing query sentences into multiple levels of deep query conditions, acquiring limiting parameters based on the multiple levels of deep query conditions, determining the number of query limits corresponding to each level of deep query based on the limiting parameters, carrying out multiple levels of deep query on an attribute graph by utilizing the multiple levels of deep query conditions and the number of query limits corresponding to each level of deep query to obtain target query results, wherein the second number of the query results obtained by each level of deep query is not larger than the number of query limits corresponding to the corresponding level, storing the attribute graph in the graph database, updating the number of query limits corresponding to at least one level of deep query in response to the target query results not meeting preset conditions, and continuing to carry out the deep query according to the updated number of query limits until the target query results meet the preset conditions. The method comprises the steps of updating the number of query limits corresponding to at least one level of deep query, continuing to perform deep query according to the number of updated query limits, judging whether a query result obtained by the level of deep query comprises all nodes belonging to the level of the current in an attribute graph or not according to the last level of the level of deep query as the level of the current, if not, updating the number of query limits corresponding to the level of the current, inquiring nodes which are not queried at the level of the current based on the number of the updated query limits corresponding to the level of the current and the depth query condition of the level of the current, obtaining updated target query results, responding to the fact that the updated target query result does not meet preset conditions and the current level has no query nodes, executing the updating the number of query limits corresponding to the level of the current and the subsequent steps again until the updated target query result meets preset conditions or the updated target query result meets preset conditions, responding to the updated target query result, and returning to the updated target query result. The preset conditions comprise that the target query result meets the query statement or the target query result meets the query statement, and the number of the target query results is larger than a threshold value. The multi-level deep queries comprise first-level deep queries and non-first-level deep queries, and the at least one-level deep queries requiring updating of the limited number of queries comprise at least one-level non-first-level deep queries. Wherein updating the number of query restrictions includes expanding the number of query restrictions. The method comprises the steps of determining the number of query limits corresponding to each level of deep query based on the limiting parameters, judging whether the limiting parameters are larger than preset parameters, setting the number of query limits to be the number of returned results in response to the limiting parameters being not larger than the preset parameters, obtaining the number of returned results based on query sentences, and setting the number of query limits to be a preset multiple of the product of the number of returned results and the limiting parameters in response to the limiting parameters being larger than the preset parameters. The multi-level deep query conditions comprise first-level deep query conditions and non-first-level deep query conditions, wherein the depth of a no