Materialized view generation method and system

By iteratively optimizing the materialized view generation method in the graph database, the problem of data redundancy and poor computing efficiency during materialized view generation in the prior art is solved, and efficient materialized view generation is realized, which is suitable for complex graph database query scenarios.

CN119848062APending Publication Date: 2025-04-18ZHEJIANG CHUANGLIN TECH CO LTD

Patent Information

Application Number
CN202510323988.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-19
Publication Date
2025-04-18

AI Technical Summary

Technical Problem

The prior art has problems of data redundancy and poor computing efficiency when generating materialized views in graph databases, making it difficult to effectively accelerate complex graph traversal and relationship query.

Method used

In the materialized view generation method, the graph data is queryed based on the target query statement, and the data structure of the query result data is optimized by iterating the task items, including vertex expansion, merging, edge optimization, etc., until an efficient materialized view is generated.

Benefits of technology

It improves the storage and computing efficiency of materialized views, improves query performance, and makes it suitable for complex graph database query scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119848062A_ABST
    Figure CN119848062A_ABST
Patent Text Reader

Abstract

The invention discloses a materialized view generation method and system, and the method comprises the following steps: carrying out the iterative optimization of query result data based on configured task items until a corresponding materialized view is generated, the task items are divided into a conversion task and a plurality of optimization tasks, and the method specifically comprises the steps: determining a current task item; if the current task item is an optimization task, entering an optimization iteration step, and executing the following steps in the optimization iteration step: acquiring current to-be-optimized data; acquiring corresponding task configuration data; and expanding or merging vertexes in the current to-be-optimized data based on the task configuration data, or expanding or merging edges in the current to-be-optimized data so as to optimize and update the current to-be-optimized data. According to the method, the query result data is iteratively optimized on the basis of the query requirement, so that the generated materialized view is suitable for a graph database scene.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing, and in particular to a materialized view generation method and system for a graph database. Background Art

[0002] Relational databases are based on a relational model, where data is stored in tables and relationships are established through foreign keys; Graph databases are based on graph models. Data is stored in the form of nodes and edges, and relationships are directly expressed through connections between nodes. The fundamental difference between the two data models makes it difficult to directly transplant the materialized view technology based on table structure in relational databases to graph databases, and its effect in accelerating complex graph traversal and relationship queries commonly seen in graph databases is not satisfactory. Summary of the invention

[0003] The present invention aims at solving the above-mentioned defects through the following technical solutions: A materialized view generation method for a graph database includes the following steps: Query the target graph data based on the target query statement to obtain the corresponding query result data; The query result data is iteratively optimized based on the configured task items until the corresponding materialized view is generated. The task items are divided into conversion tasks and several optimization tasks, specifically: Determine the current task item; If the current task item is a conversion task, obtain the current data to be optimized, and convert the current data to be optimized into a corresponding materialized view and output it; If the current task item is an optimization task, enter the optimization iteration step, and in the optimization iteration step, perform the following steps: Get the current data to be optimized; Obtaining task configuration data corresponding to the optimization task; Based on the task configuration data, the vertices in the current data to be optimized are expanded or merged, or the edges in the current data to be optimized are expanded or merged, so as to optimize and update the current data to be optimized.

[0004] The target query statement is used to indicate the target graph data to be queried, and is also used to indicate the query content and filtering conditions. Technical personnel in this field can set the target query statement according to actual conditions.

[0005] Nowadays, the generation of materialized views in graph database scenarios also focuses on the design and optimization of target query statements, such as predicting the query content that may be needed later, or designing query content based on query frequency and demand priority to make the obtained materialized view information valuable; That is, in the prior art, after determining the target query statement, the query result corresponding to the target query statement is directly converted into a materialized view. This solution has the defects of data redundancy and poor computing efficiency.

[0006] The present application can configure the corresponding task configuration data according to the actual optimization target, iteratively optimize the query result data obtained by the query, optimize the data structure of the query result data by expanding or merging edges and vertices, improve the storage and computing efficiency of the obtained materialized view, and improve the query performance of the materialized view.

[0007] As an implementable method, the optimization task includes a vertex expansion task, which is used to create corresponding expansion vertices in the current data to be optimized based on key query requirements, and to create corresponding edges for the expansion vertices.

[0008] Further: The vertex expansion tasks include attribute vertex expansion tasks, the corresponding key query requirements are target attribute types, and are used to expand multiple attribute vertices corresponding to the target attribute type in the current data to be optimized; The specific steps of expanding the current data vertex to be optimized in the corresponding optimization iteration step based on the attribute vertex expansion task are: Get the task configuration data including the target attribute type; Based on the task configuration data, extract several attributes corresponding to the target attribute type from the current data to be optimized to obtain corresponding key attributes; Create attribute vertices corresponding to the key attributes one by one, and connect the attribute vertices with vertices having corresponding attributes.

[0009] That is, when the key query content involves enumerable attributes, a corresponding attribute vertex is created for each attribute in the current data to be optimized, so as to quickly query objects with corresponding attributes and effectively improve query performance.

[0010] Further: The vertex expansion tasks include relationship vertex expansion tasks, the corresponding key query requirement is the target relationship, and are used to expand the relationship vertices corresponding to the target relationship in the current data to be optimized; Based on the relationship vertex expansion task, the specific steps of performing vertex expansion on the current data to be optimized in the corresponding optimization iteration step are: Get the task configuration data including the target relationship; Based on the task configuration data, extracting a target edge corresponding to the target relationship from the current data to be optimized; Acquire a plurality of groups of vertex pairs based on the target edge; A corresponding relationship vertex is created for each vertex pair, and each vertex in the vertex pair is connected to the corresponding relationship vertex, and the relationship vertex records each target relationship generated between the corresponding vertex pairs.

[0011] That is, when the key query content involves detailed information on the interaction relationship between nodes, by establishing a corresponding intermediate vertex between two vertices with the interaction relationship, the details of the interaction between the two vertices are stored using the intermediate vertex, which facilitates subsequent retrieval analysis based on the interaction details.

[0012] Further: The vertex expansion tasks include statistical vertex expansion tasks; The corresponding key query requirement is a statistical indicator, which is used to expand a statistical vertex for storing the statistical indicator for the target object in the current data to be optimized.

[0013] As an implementable method: The optimization task includes a subgraph abstraction task, which is used to merge the subgraphs specified in the current data to be optimized into one vertex; Based on the subgraph abstract task, the specific steps for merging the vertices of the current data to be optimized in the corresponding optimization iteration step are: Extracting subgraphs from the current data to be optimized to obtain a plurality of candidate subgraphs; Based on the corresponding data to be configured, select a subgraph to be merged from the candidate subgraphs, and configure the merged vertex information for each subgraph to be merged, so as to generate corresponding task configuration data; Based on the task configuration data and the corresponding optimization rules, each subgraph to be merged in the current data to be optimized is converted into a corresponding merged vertex.

[0014] Based on actual query needs, this embodiment merges the subgraphs that are queried and analyzed as a whole into one vertex, effectively reducing data redundancy.

[0015] As an implementable method: The optimization tasks include edge optimization tasks, which are used to aggregate or split the relevant edges in the current data to be optimized based on the relationship query granularity; The optimization configuration template of the optimization task corresponding to the edge optimization includes: Data to be configured for indicating the relationship query object and its relationship query granularity; A configuration rule for indicating obtaining the data to be configured to generate corresponding task configuration data; The optimization rules are used to aggregate or split the corresponding edges in the current data to be optimized based on the task configuration data.

[0016] Further: The edge optimization tasks include edge aggregation tasks and edge splitting tasks; The edge aggregation task is used to merge several types of edges corresponding to the relationship query object in the current data to be optimized according to the configured relationship query object and relationship query granularity according to the relationship query granularity; This application can effectively reduce data redundancy through the design of edge aggregation.

[0017] The edge splitting task is used to take the edge corresponding to the relationship query object in the current data to be optimized as the target edge according to the configured relationship query object and relationship query granularity, and split the target edge based on the attribute corresponding to the relationship query granularity in the target edge to obtain fine-grained edges corresponding to the attribute one by one; Through the design of edge splitting, this application can split an edge with multiple attributes into multiple edges according to its attributes according to actual query needs, which can improve query performance, and the fine-grained edges do not interfere with each other, which facilitates subsequent in-depth analysis of the corresponding relationship.

[0018] As an implementable method: The optimization task also includes an edge derivation task, which is used to pre-create corresponding derived edges in the current data to be optimized based on the indirect relationship query requirements.

[0019] An indirect relationship refers to a relationship between a first vertex and a second vertex that is associated through at least one vertex. This application is for a frequently queried indirect relationship, and a derived edge is directly created for the corresponding two vertices to represent the indirect relationship. For example, an edge connecting the first vertex and the second vertex is created. When querying, there is no need to perform multiple hops to find that the vertex that has the indirect relationship with the first vertex is the second vertex.

[0020] A materialized view generation system is used in the steps of any one of the above materialized view generation methods.

[0021] The present invention has significant technical effects due to the adoption of the above technical solution: During the materialized view generation process, technical personnel in this field can configure corresponding optimization tasks according to actual query requirements to achieve optimization adjustment of query result data until the optimization is completed. Then, configure the transformation task to convert the final optimization adjustment result into the corresponding materialized view, so that the obtained materialized view is suitable for complex graph database query scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0023] Figure 1 It is a schematic diagram of the workflow of a materialized view generation method of the present invention; Figure 2 It is a flowchart corresponding to the task item being an optimization task. DETAILED DESCRIPTION

[0024] The present invention is further described in detail below in conjunction with embodiments. The following embodiments are for explanation of the present invention but the present invention is not limited to the following embodiments.

[0025] An embodiment of the present application provides a materialized view generation method, referring to Figure 1 , specifically including the following steps: S100, determining query result data; Based on the configured target query statement and at least one target graph data, the query obtains corresponding query result data, and the query result data includes sub-result data corresponding one-to-one to the target graph data.

[0026] Those skilled in the art may adopt existing query solutions, such as using GQL (Graph Query Language, a language for querying graph databases) to query one or more corresponding graph data based on a target query statement to obtain corresponding query result data, which is not limited in detail in this specification.

[0027] S200, iteratively optimizing query result data based on the configured task items until a corresponding materialized view is generated; The task items are divided into conversion tasks and several optimization tasks, and each optimization task corresponds to a different optimization goal; In the current research field of materialized view generation technology, the research focus is generally on the selection and optimization strategy of query statements. For example, the materialized view generation scheme is optimized by analyzing the request frequency of various query tasks and the priority of query requirements. However, this single-dimensional optimization approach ignores other potential optimization directions in the materialized view generation process to a certain extent, resulting in limitations in the overall optimization effect. In addition, it is difficult to effectively accelerate query tasks in graph data scenarios by simply designing query statements.

[0028] During the materialized view generation process, those skilled in the art may configure corresponding optimization tasks according to actual needs, thereby optimizing and adjusting the query result data until the optimization is completed, and then configure a conversion task to convert the final optimization adjustment result into a corresponding materialized view.

[0029] Specifically: S210: Determine the current task item.

[0030] In actual applications, users can generate corresponding optimization tasks by proposing optimization requests containing optimization targets based on actual needs, or proposing conversion requests to generate corresponding conversion tasks; they can also automatically generate one or more candidate optimization targets based on the analysis of the target query statement, and determine the current task item based on the candidate optimization targets. This specification does not limit it in detail.

[0031] S220, if the current task item is an optimization task, enter the optimization iteration step; Reference Figure 2 , in the optimization iteration step, perform the following steps: S221, obtaining the current data to be optimized; When entering the optimization iteration step for the first time, the query result data is used as the current data to be optimized; S222, obtaining corresponding task configuration data; In this embodiment, a corresponding optimization configuration template is extracted from a preset template library based on the optimization task, and corresponding task configuration data is generated based on the optimization configuration template; The optimization configuration template is used to indicate the data processing steps performed for the corresponding optimization operation, and the data required for performing the data processing steps; S223. Expand or merge the vertices in the current data to be optimized, or expand or merge the edges in the current data to be optimized based on the task configuration data, so as to optimize and update the current data to be optimized.

[0032] S230: If the current task item is a conversion task, obtain current data to be optimized, and convert the current data to be optimized into a corresponding materialized view and output it.

[0033] Those skilled in the art may, for example, implement various task items based on the declarative query statements DEFINE VERTEX (define a node), DEFINE EDGE (define an edge), and CREATE VIEW (generate a view).

[0034] In specific implementation, a template library is created in advance, and the template library includes optimization configuration templates corresponding to various optimization tasks. As an embodiment, the optimization configuration template includes: The data to be configured is used to indicate the data content of the configuration required to perform the optimization task; Configuration rules, used to indicate rules for obtaining the data to be configured to generate corresponding task configuration data; Optimization rules are data processing rules for performing optimization operations on corresponding vertices or edges based on task configuration data, wherein the optimization operations include expansion and merging.

[0035] In this embodiment, the types of optimization tasks are divided into vertex expansion tasks, vertex merging tasks, edge optimization tasks and edge derivation tasks.

[0036] 310. Vertex expansion tasks, used to create corresponding expansion vertices in the current data to be optimized based on key query requirements; The optimization configuration template corresponding to the vertex extension task includes: Data to be configured, which includes key query requirements; configuration rules for indicating obtaining the data to be configured to generate corresponding task configuration data, wherein the task configuration data can represent the key query requirements; The optimization rule is used to create corresponding extended vertices in the current data to be optimized based on the task configuration data, and to create edges connecting corresponding associated vertices for the extended vertices.

[0037] The vertex expansion tasks include attribute vertex expansion tasks, relationship vertex expansion tasks, and statistical vertex expansion tasks.

[0038] 311. Attribute vertex expansion task; The corresponding key query requirement is the target attribute, which is used to expand one or more attribute vertices corresponding to the target attribute in the current data to be optimized; Based on the key attribute expansion task, the specific steps for performing vertex expansion on the current data to be optimized in the corresponding optimization iteration step are: Generate task configuration data including target attribute types; Based on the task configuration data, extract several attributes corresponding to the target attribute type from the current data to be optimized to obtain corresponding key attributes; Create attribute vertices corresponding to the key attributes one by one, and connect the attribute vertices with vertices having corresponding attributes.

[0039] For example, the "skill" attribute of a job applicant is a key query requirement in a recruitment scenario. The existing materialized view generation technology directly generates a materialized view based on the query results of the set query statement in the original relationship graph, that is, the view conversion is performed based on the data structure of the original relationship graph. At this time, although the obtained materialized view contains the "skill" attribute to meet the query requirements, if you need to query people with a certain skill, you need to traverse the skill attributes of each job applicant; Taking "Skills - Python Skills" as an example, the specific steps for optimizing the data structure based on key query requirements in this embodiment are as follows: Based on the target attribute type "skill", query all specific attributes contained in the current data to be optimized, such as "Python skill"; Create a corresponding attribute vertex for each attribute, such as creating a corresponding attribute vertex for "Python skills"; Connect the vertex of the job seeker with "Python skill" to the attribute vertex corresponding to the "Python skill" to indicate that the job seeker has Python skill; In the query application scenario of materialized views, if you need to query job seekers with "Python skills", there is no need to traverse the attributes of all job seekers. You can directly perform edge queries based on the corresponding attribute vertices, which can significantly improve the efficiency and intuitiveness of the query.

[0040] 312, Relationship Vertex Extension Task; The corresponding key query requirement is the target relationship, which is used to expand the relationship vertices corresponding to the target relationship in the current data to be optimized.

[0041] As above, the target relationship can be obtained by parsing the target query statement, and Based on the relationship vertex expansion task, the specific steps for expanding the vertices of the current data to be optimized in the corresponding optimization iteration step are: Generate task configuration data including target relationships; Based on the task configuration data, extracting a target edge corresponding to the target relationship from the current data to be optimized; Acquire a plurality of groups of vertex pairs based on the target edge; A corresponding relationship vertex is created for each vertex pair, and each vertex in the vertex pair is connected to the corresponding relationship vertex, and the relationship vertex records each target relationship generated between the corresponding vertex pairs.

[0042] For example, the key query requirement in the "transfer" relationship data bank transaction analysis scenario is that the structure of the existing transfer graph generally includes account nodes and edges representing transfer relationships. The relevant attributes of the transfer are stored on the edges, including amount, time, payment method (bank transfer, Alipay transfer, WeChat transfer) and other information; In this embodiment, based on the "transfer" relationship, each pair of user vertices with a transfer relationship is queried, and a "transfer record" relationship vertex is created between each pair of user vertices. The relationship vertex is connected to the corresponding two users respectively, thereby more intuitively expressing the transfer process between the two users, which can effectively improve the corresponding query analysis efficiency.

[0043] 313. Statistical vertex extension task; The corresponding key query requirement is a statistical index, which is used to expand a statistical vertex for storing the corresponding statistical index for the target object in the current data to be optimized.

[0044] Based on the statistical vertex expansion task, the specific steps of performing vertex expansion on the current optimization data in the corresponding optimization iteration step are: Generate corresponding task configuration data, wherein the task configuration data is used to indicate a target object, a statistical indicator, and a statistical rule corresponding to the statistical indicator; Extracting corresponding vertices from the current optimization data based on the statistical object to obtain target vertices; Based on the statistical indicators and statistical rules, a statistical vertex connected to each target vertex is created, and the statistical vertex is connected to the vertex that provides original data for it. The statistical vertex is used to store the statistical results corresponding to the statistical indicators.

[0045] For example, in a bank account management scenario, it is necessary to statistically analyze the total balance of each user. The corresponding data to be optimized includes user vertices, account vertices, and edges connecting the user vertices and account vertices. In this scenario, the user can be used as the target object, and the total account balance can be used as the statistical indicator. The statistical rule is to sum the balances of all the user's accounts. In this way, a statistical vertex can be created for each user in the data to be optimized, and the statistical vertex is connected to each account vertex. The statistical node stores the total balance of all the corresponding user's accounts.

[0046] In this embodiment, vertices are expanded based on key query requirements. While optimizing the data structure of the corresponding graph data based on the query requirements, the corresponding materialized view data structure is also optimized, effectively enhancing the expression ability of the corresponding materialized view, making hidden relationships visible, and improving the query performance of the resulting materialized view, so that it can effectively accelerate the corresponding graph query tasks.

[0047] 320. Vertex merging tasks, used to create corresponding extended vertices in the current data to be optimized based on merging requirements; The optimization configuration template corresponding to the vertex merging task includes: Used to indicate the data to be configured for the vertices to be merged; A configuration rule for indicating obtaining the data to be configured to generate corresponding task configuration data; An optimization rule for merging the vertices to be merged in the current data to be optimized based on the task configuration data.

[0048] The vertex merging tasks include cross-graph merging tasks, similar vertex merging tasks, and subgraph abstraction tasks.

[0049] 321. Merge tasks across graphs; When the current optimized data includes multiple graph data, the same or similar vertices in different graph data are merged based on the cross-graph merging task.

[0050] Based on the cross-graph merging task, the specific steps of merging vertices of the current optimized data in the corresponding optimization iteration step are: Based on the data to be configured, the graph data involved in the merge in the current optimized data and the vertex types involved in the merge in the corresponding graph data are configured to obtain corresponding task configuration data; Based on the configured graph data and vertex types, vertex matching is performed to obtain a plurality of vertex groups to be merged, wherein each vertex in the vertex groups to be merged belongs to a different graph data, and the primary keys of each vertex are the same or similar. Those skilled in the art may use an existing similarity algorithm to calculate the similarity of the corresponding primary keys, which will not be described in detail in this embodiment; Merge multiple vertices in the vertex group to be merged to obtain a corresponding target vertex, and the obtained target vertex inherits the edge data of all vertices in the vertex group to be merged.

[0051] In a multi-graph environment, the same or similar entities may be stored in different graph data. For example, the user data corresponding to the same user may exist in both the "social network graph" and the "e-commerce transaction graph"; By merging the same or similar vertices in different graph data, it is possible to reduce duplicate data storage and optimize the data structure.

[0052] 322. Similar vertex merging task is used to merge similar vertices in the same graph data.

[0053] 323. Subgraph abstraction task: Used to merge the subgraphs specified in the current data to be optimized into one vertex; The specific steps of merging the vertices of the current data to be optimized in the corresponding optimization iteration step based on the subgraph abstract task are as follows: Extracting subgraphs from the current data to be optimized based on corresponding configuration rules to obtain a plurality of candidate subgraphs; Based on the corresponding data to be configured, select a subgraph to be merged from the candidate subgraphs, and configure merged vertex information for each subgraph to be merged, wherein the vertex information includes a primary key and attributes, and generate corresponding task configuration data; Based on the task configuration data and the corresponding optimization rules, each subgraph to be merged in the current data to be optimized is converted into a corresponding merged vertex, that is, a corresponding merged vertex is created based on the merged vertex information configured for the subgraph to be merged, and the merged vertex inherits the relationship between each vertices in the corresponding subgraph to be merged and the vertices outside the subgraph.

[0054] For example, an enterprise has several branches, but in actual application scenarios, all of its companies are generally queried and analyzed as a whole. Based on the materialized view generation solution proposed in this embodiment, the subgraphs corresponding to the enterprise can be merged into one vertex, and the relationship data between the branches is not saved.

[0055] Based on actual query needs, this embodiment uses all or part of the subgraphs as a whole to participate in query analysis. By abstracting the subgraph as a vertex, it is possible to reduce data redundancy of the obtained materialized data, optimize the data structure and improve the corresponding query performance.

[0056] This embodiment can effectively reduce data redundancy, reduce storage space usage, optimize storage structure, reduce query calculation costs, and improve retrieval speed through the design of the vertex merging operation.

[0057] 330. Edge optimization tasks, including edge aggregation tasks and edge splitting tasks; Edge optimization tasks are used to aggregate or split related edges in the current data to be optimized based on the relationship query granularity; The optimization configuration template of the optimization task corresponding to the edge optimization includes: Data to be configured for indicating the relationship query object and its relationship query granularity; A configuration rule for indicating obtaining the data to be configured to generate corresponding task configuration data; The optimization rules are used to aggregate or split the corresponding edges in the current data to be optimized based on the task configuration data.

[0058] Edge aggregation is the merging of opposite edges, and edge splitting is the expansion of opposite edges.

[0059] In this embodiment, when the relationship query granularity is whether there is interaction, edge aggregation is performed, and when the relationship query granularity is the attribute of the edge, edge splitting is performed.

[0060] Edge aggregation is used to aggregate several types of edges corresponding to the relationship query object in the current data to be optimized according to the relationship query granularity according to the configured relationship query object and relationship query granularity; For example, in social network analysis, if the query requirement is only whether there is interaction between two users, the edges of subdivided types such as "comments", "likes", and "follows" can be aggregated to form a coarse-grained edge between the corresponding vertices to represent whether there is interaction.

[0061] The design of edge aggregation in this embodiment can further reduce data redundancy and optimize the data structure.

[0062] Edge splitting is used to take the edge corresponding to the relationship query object in the current data to be optimized as the target edge according to the configured relationship query object and relationship query granularity, and split the target edge based on the attribute corresponding to the relationship query granularity in the target edge to obtain fine-grained edges corresponding one-to-one to the attribute.

[0063] For example, in social network analysis, a "user interaction" edge may contain multiple attributes such as likes, comments, and shares. When the relationship query granularity corresponds to the specific edge attributes, the "user interaction" edge can be split into independent edges such as "likes", "comments", and "shares" based on its attributes to avoid interference from irrelevant data.

[0064] Through the design of edge splitting, this implementation can split an edge containing multiple attributes into multiple sub-edges with more semantics based on the query granularity to improve the flexibility of the query.

[0065] 330, side-derived tasks; The edge derivation task is used to create corresponding derived edges in the current data to be optimized based on the indirect relationship query requirements, which is an extension of the edge; The optimization configuration template corresponding to the edge derivation task includes: Data to be configured to represent indirect relationship query requirements; A configuration rule for indicating obtaining the data to be configured to generate corresponding task configuration data; Used to create corresponding derived edges in the current data to be optimized based on the task configuration data.

[0066] In some query scenarios, a "multi-hop" calculation is required to find the relationship between two points. This embodiment speeds up the query by creating corresponding derived edges to directly connect the corresponding two vertices.

[0067] In practical applications, the node pairs for which corresponding derived edges need to be created can be directly specified based on actual needs, or the query rules for the target indirect relationship can be configured. In the current optimized data, the node pairs that satisfy the target indirect relationship are extracted based on the query rules, and corresponding derived edges are created for the extracted node pairs. This embodiment does not limit it in detail.

[0068] Through the design of the above-mentioned optimization tasks, this embodiment has stronger semantic expression capabilities while optimizing storage and accelerating queries. It is suitable for complex graph database application scenarios such as financial risk control, social network analysis, and recommendation systems.

[0069] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0070] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0071] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0072] The present invention is described with reference to the flowcharts and / or block diagrams of the method, terminal device (system), and computer program product according to the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0073] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0074] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0075] It should be noted that: The "one embodiment" or "embodiment" mentioned in the specification means that the specific features, structures or characteristics described in conjunction with the embodiment are included in at least one embodiment of the present invention. Therefore, the phrases "one embodiment" or "embodiment" appearing in various places throughout the specification do not necessarily refer to the same embodiment.

[0076] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.

[0077] In addition, it should be noted that the shapes and names of the parts and components of the specific embodiments described in this specification may be different. Any equivalent or simple changes made based on the structure, features and principles described in the patent concept of the present invention are included in the protection scope of the patent of the present invention. The technicians in the technical field of the present invention can make various modifications or supplements to the specific embodiments described or replace them in a similar manner, as long as they do not deviate from the structure of the present invention or exceed the scope defined by the claims, they should all fall within the protection scope of the present invention.

Claims

1. A materialized view generation method for a graph database, characterized in that: The following steps are involved: Query the target graph data based on the target query statement to obtain the corresponding query result data; The query result data is iteratively optimized based on the configured task items until the corresponding materialized view is generated. The task items are divided into conversion tasks and several optimization tasks, specifically: Determine the current task item; If the current task item is a conversion task, obtain the current data to be optimized, and convert the current data to be optimized into a corresponding materialized view and output it; If the current task item is an optimization task, enter the optimization iteration step, and in the optimization iteration step, perform the following steps: Get the current data to be optimized; Obtaining task configuration data representing corresponding optimization objectives; Based on the task configuration data, the vertices in the current data to be optimized are expanded or merged, or the edges in the current data to be optimized are expanded or merged, so as to optimize and update the current data to be optimized.

2. The materialized view generation method according to claim 1, characterized in that: The optimization tasks include vertex expansion tasks, which are used to create corresponding expansion vertices in the current data to be optimized based on key query requirements, and to create corresponding edges for the expansion vertices.

3. The materialized view generation method according to claim 2, characterized in that: The vertex expansion tasks include attribute vertex expansion tasks, the corresponding key query requirements are target attribute types, and are used to expand multiple attribute vertices corresponding to the target attribute type in the current data to be optimized; The specific steps of expanding the current data vertex to be optimized in the corresponding optimization iteration step based on the attribute vertex expansion task are: Get the task configuration data including the target attribute type; Based on the task configuration data, extract several attributes corresponding to the target attribute type from the current data to be optimized to obtain corresponding key attributes; Create attribute vertices corresponding to the key attributes one by one, and connect the attribute vertices with vertices having corresponding attributes.

4. The materialized view generation method according to claim 2, characterized in that: The vertex expansion tasks include relationship vertex expansion tasks, the corresponding key query requirement is the target relationship, and are used to expand the relationship vertices corresponding to the target relationship in the current data to be optimized; Based on the relationship vertex expansion task, the specific steps of performing vertex expansion on the current data to be optimized in the corresponding optimization iteration step are: Get the task configuration data including the target relationship; Based on the task configuration data, extracting a target edge corresponding to the target relationship from the current data to be optimized; Acquire a plurality of groups of vertex pairs based on the target edge; A corresponding relationship vertex is created for each vertex pair, and each vertex in the vertex pair is connected to the corresponding relationship vertex, and the relationship vertex records each target relationship generated between the corresponding vertex pairs.

5. The materialized view generation method according to claim 2, characterized in that: The vertex expansion tasks include statistical vertex expansion tasks; The corresponding key query requirement is a statistical indicator, which is used to expand a statistical vertex for storing the statistical indicator for the target object in the current data to be optimized.

6. The materialized view generation method according to claim 1, characterized in that: The optimization task includes a subgraph abstraction task, which is used to merge the subgraphs specified in the current data to be optimized into one vertex; Based on the subgraph abstract task, the specific steps for merging the vertices of the current data to be optimized in the corresponding optimization iteration step are: Extracting subgraphs from the current data to be optimized to obtain a plurality of candidate subgraphs; Based on the corresponding data to be configured, select a subgraph to be merged from the candidate subgraphs, and configure the merged vertex information for each subgraph to be merged, so as to generate corresponding task configuration data; Based on the task configuration data and the corresponding optimization rules, each subgraph to be merged in the current data to be optimized is converted into a corresponding merged vertex.

7. The materialized view generation method according to claim 1, characterized in that: The optimization tasks include edge optimization tasks, which are used to aggregate or split the relevant edges in the current data to be optimized based on the relationship query granularity.

8. The materialized view generation method according to claim 7, characterized in that: The edge optimization tasks include edge aggregation tasks and edge splitting tasks; The edge aggregation task is used to merge several types of edges corresponding to the relationship query object in the current data to be optimized according to the configured relationship query object and relationship query granularity according to the relationship query granularity; The edge splitting task is used to take the edge corresponding to the relationship query object in the current data to be optimized as the target edge according to the configured relationship query object and relationship query granularity, and split the target edge based on the attribute corresponding to the relationship query granularity in the target edge to obtain fine-grained edges corresponding one-to-one to the attribute.

9. The materialized view generation method according to claim 1, characterized in that: The optimization task also includes an edge derivation task, which is used to pre-create corresponding derived edges in the current data to be optimized based on the indirect relationship query requirements.

10. A materialized view generation system, characterized in that: Used to execute the steps of any one of the materialized view generation methods of claims 1 to 9.

Citation Information

Patent Citations

  • Query task optimization method based on science and technology consultation large-scale graph data

    CN114020781A

  • Knowledge graph retrieval method and system based on pattern matching

    CN117763200A

  • Materialized view generation method and device, electronic equipment, storage medium and program product

    CN118673046A

  • Database query method and device, medium and computer program product

    CN118885507A

Cited By

  • View materialization method and system for sub-graph matching query

    CN121579587A

  • Method and system for view materialization for subgraph matching queries

    CN121579587B