A cache multiplexing method and related devices
By converting query commands into attribute graphs and reusing execution plans from the cache based on similarity matching algorithms, the problem of long SQL statement optimization time in database systems is solved, and matching efficiency is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN HUAWEI CLOUD COMPUTING TECHNOLOGIES CO LTD
- Filing Date
- 2023-08-04
- Publication Date
- 2026-07-31
AI Technical Summary
In existing database systems, the text similarity matching algorithm is inefficient during SQL statement optimization, resulting in a long optimization time.
The query command is converted into an abstract attribute graph, and based on node similarity and/or edge similarity, a similar attribute graph is determined from the cache, and its execution plan is reused to obtain the query results.
It improves the matching efficiency of query commands and reduces the optimization time of SQL statements.
Smart Images

Figure CN117149824B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computers, and more particularly to a cache reuse method and related equipment. Background Technology
[0002] Database systems can model real-world objects and perform data storage and query processing. Users can interact with database systems using Structured Query Language (SQL) as the standard query language. A key characteristic of SQL is its declarative nature; users only need to tell the database system what data they need, not how to retrieve it. Therefore, database systems need to compile and optimize user SQL queries into a form that can be executed internally. However, SQL query optimization is time-consuming, and reducing optimization time has become a pressing issue.
[0003] One approach involves providing an execution plan cache within the database system. This cache stores the complete execution plan of the SQL statement and compares the cached SQL statement with the input SQL statement using a text similarity matching algorithm. When a cached SQL statement contains an identical copy of the input SQL statement, the cached plan is matched, and the SQL statement is optimized.
[0004] This method compares SQL statements, meaning it uses a text similarity matching algorithm, which is not very efficient. Summary of the Invention
[0005] This application provides a cache reuse method and related device. In the cache reuse method, a first attribute graph corresponding to a query instruction is constructed. The at least two first data tables and at least one connection relationship included in the query instruction are converted into at least two first nodes and at least one first edge in the first attribute graph. Then, based on node similarity and / or edge similarity, a second attribute graph similar to the first attribute graph is determined from the cache, and the execution plan of the second attribute graph is reused to process the query instruction, thereby obtaining the query result. In other words, in this application, the textual query instruction is converted into an abstract attribute graph, and the execution plan in the cache is reused based on a similarity graph matching algorithm, thereby improving matching efficiency.
[0006] The first aspect of this application provides a method for cache reuse, which is applied to a computer device and includes:
[0007] The computer device can obtain query instructions, which include at least two first data tables and at least one join relationship. The computer device can obtain query instructions by acquiring a user-input SQL query statement, which includes at least two first data tables and at least one join relationship to represent the data required by the user. Based on the query instructions, the computer device can construct a first attribute graph, which includes at least two first nodes and at least one first edge. The at least two first nodes correspond one-to-one with at least two first data tables, and the at least one first edge corresponds one-to-one with at least one join relationship. That is, the first data tables and the join relationships between them are represented in the first attribute graph as first nodes and the first edges between them. The computer device also determines a second attribute graph similar to the first attribute graph from a cache based on node similarity and / or edge similarity. The cache contains at least one attribute graph, where the second attribute graph is similar to the first attribute graph and includes at least two second nodes corresponding one-to-one with the at least two first nodes, and at least one second edge corresponding one-to-one with the at least one first edge. After determining the second attribute graph, the computer device can reuse the execution plan of the second attribute graph to process the query command, thereby obtaining the query result of the query command.
[0008] As can be seen from the above technical solution, this application has the following advantages: In this application, the textual query instruction is converted into an abstract first attribute graph. Then, based on node similarity and / or edge similarity, the first attribute graph is matched with the attribute graph in the cache to determine a second similar graph that matches the first similar graph. The execution plan of the second attribute graph is then reused to process the query instruction to obtain the query results. Compared with traditional text similarity matching algorithms, this improves matching efficiency.
[0009] In one possible implementation of the first aspect, the computer device determines a second attribute graph similar to the first attribute graph from a cache based on node similarity and / or edge similarity, including: determining the second attribute graph from the cache based on node similarity. Specifically, the computer device may sequentially perform similarity matching between at least two first nodes and nodes in a candidate attribute graph set in the cache, from the first node to the last node. The candidate attribute graph set includes at least one attribute graph. That is, the computer device compares each of the at least two first nodes in the first attribute graph, starting from the first node, with nodes in each attribute graph in the candidate attribute graph set. In other words, when performing node similarity matching, the computer device compares the first node of the first attribute graph with the first node of each attribute graph, the next node of the first node with the next node of the first node of each attribute graph, and so on. During the comparison process, if there are nodes in the third attribute graph of the candidate attribute graph set that do not meet the node similarity conditions, the computer device may stop similarity matching with the third attribute graph, i.e., determine that this third attribute graph is not an attribute graph that matches the first attribute graph. If at least two third nodes in the fourth attribute graph of a candidate attribute graph are one-to-one similar to at least two first nodes (i.e., the nodes in the fourth attribute graph and the nodes in the first attribute graph satisfy the node similarity condition), then the computer device can determine the second attribute graph based on the fourth attribute graph. It should be noted that the number of fourth attribute graphs is not limited here; a fourth attribute graph refers to an attribute graph in the candidate attribute graph set where at least two third nodes are one-to-one similar to at least two first nodes.
[0010] In this application, when performing similarity matching between at least two first nodes of the first attribute graph and nodes in the candidate attribute graph set, the comparison is performed sequentially from the first node to the last node. If a node that does not meet the node similarity condition is found, the computer device will stop comparing with that attribute graph, that is, it will no longer perform similarity matching on subsequent nodes, thereby narrowing the comparison range of the execution plan, reducing the comparison time, and thus reducing the optimization time of the SQL statement.
[0011] In one possible implementation of the first aspect, determining the second attribute graph based on the fourth attribute graph includes: the computer device determining the attribute graph in the fourth attribute graph that has the lowest execution cost or the highest node similarity as the second attribute graph. Optionally, the node similarity mentioned here can be the average of the similarities of at least two first nodes and at least two third nodes, or a weighted value; the specifics are not limited here. The weights of each node can be determined according to the actual application; the specifics are not limited here.
[0012] In this application, when there are multiple fourth attribute graphs that satisfy the node similarity condition with nodes in the first attribute graph, the computer device can filter them and select the attribute graph with the lowest execution cost as the second attribute graph. This minimizes the execution cost of the execution plan reused by the computer device, reducing the execution cost of processing query instructions. Alternatively, the computer device can select the attribute graph with the highest node similarity as the second attribute graph, thereby ensuring the similarity between the first and second attribute graphs and improving the accuracy of the matched execution plan.
[0013] In one possible implementation of the first aspect, the execution cost is determined based on the size of the fourth attribute graph. Node similarity is determined based on the sizes of the first and fourth attribute graphs, and / or the index definitions of the first and fourth attribute graphs.
[0014] In this application, there are multiple possible ways to determine node similarity, which enriches the implementation methods of the technical solution of this application and enhances the flexibility of the technical solution of this application.
[0015] In one possible implementation of the first aspect, the computer device determines a second attribute graph similar to the first attribute graph from a cache based on node similarity and / or edge similarity, including: determining the second attribute graph based on edge similarity. Specifically, the computer device may sequentially perform similarity matching between at least one first edge and edges in a candidate attribute graph set in the cache, from the first edge to the last edge. The candidate attribute graph set includes at least one attribute graph. That is, the computer device compares at least one first edge in the first attribute graph, starting from the first edge, with the edges of each attribute graph in the candidate attribute graph set. In other words, when performing edge similarity matching, the computer device compares the first edge of the first attribute graph with the first edge of each attribute graph, the next edge of the first edge with the next edge of the first edge of each attribute graph, and so on. Here, the first edge refers to the edge between the next node of the first node, corresponding to the connection relationship between the first and second first data tables in the query instruction. The remaining edges are similar to the first edge, corresponding to the corresponding connection relationships. During edge similarity comparison, if there are edges in the fifth attribute graph of the candidate attribute graph set that do not satisfy the edge similarity condition, then the similarity matching with the fifth attribute graph is stopped, meaning that this fifth attribute graph is determined not to be a matching attribute graph with the first attribute graph. If at least one third edge in the sixth attribute graph of the candidate attribute graph set is similar to at least one first edge (i.e., the edges in the sixth attribute graph and the edges in the first attribute graph satisfy the edge similarity condition), then the computer device can determine the second attribute graph based on the sixth attribute graph. It should be noted that the number of sixth attribute graphs is not limited here; a sixth attribute graph refers to an attribute graph in the candidate attribute graph set where at least two third edges are similar to at least two first edges.
[0016] In this application, when performing similarity matching between at least two first edges of the first attribute graph and edges in the candidate attribute graph set, the comparison is performed sequentially from the first edge to the last edge. If an edge that does not meet the edge similarity condition is found, the computer device will stop comparing with that attribute graph, that is, it will no longer perform similarity matching on subsequent edges, thereby narrowing the comparison range of the execution plan, reducing the comparison time, and thus reducing the optimization time of the SQL statement.
[0017] In one possible implementation of the first aspect, determining the second attribute graph based on the sixth attribute graph includes: the computer device can determine the attribute graph with the lowest execution cost or the highest edge similarity in the sixth attribute graph as the second attribute graph. Optionally, the edge similarity mentioned here can be the average of the similarities between at least one first edge and at least one third edge, or a weighted value; the specifics are not limited here. The weights of each edge can be determined according to the actual application; the specifics are not limited here.
[0018] In this application, when there are multiple sixth attribute graphs that satisfy the edge similarity condition with the edges in the first attribute graph, the computer device can filter them and select the attribute graph with the lowest execution cost as the second attribute graph. This minimizes the execution cost of the execution plan reused by the computer device and reduces the execution cost of processing query instructions. Alternatively, the computer device can select the attribute graph with the highest edge similarity as the second attribute graph, thereby ensuring the similarity between the first and second attribute graphs and improving the accuracy of the matching execution plan.
[0019] In one possible implementation of the first aspect, the edge similarity is determined based on the hit rate of the connection condition indicated by the first edge corresponding to the first attribute graph and the hit rate of the connection condition indicated by the third edge corresponding to the sixth attribute graph, and / or the connection relationship type indicated by the first edge corresponding to the first attribute graph and the connection relationship type indicated by the third edge corresponding to the third attribute graph.
[0020] In this application, there are multiple possible ways to determine edge similarity, which enriches the implementation methods of the technical solution of this application and enhances the flexibility of the technical solution of this application.
[0021] In one possible implementation of the first aspect, the computer device determines a second attribute graph similar to the first attribute graph from a cache based on node similarity and / or edge similarity, including: determining the second attribute graph based on node similarity and edge similarity. Specifically, the computer device can perform node and edge similarity matching with at least one attribute graph in the cached attribute graph set in a "node-edge-node" order, starting from the first node. The node similarity matching and edge similarity matching are similar to the previous implementation and will not be repeated here. It should be noted that in this implementation, the similarity comparison is performed by interleaving node comparison and edge comparison. During the comparison process, when an attribute graph in the candidate attribute graph set does not meet the node similarity condition or the edge similarity condition, the computer device stops comparing with that attribute graph. That is to say, the attribute graph similar to the first attribute graph selected by the computer device is similar not only to the nodes of the first attribute graph but also to the edges of the first attribute graph. If the computer device selects multiple attribute graphs similar to the first attribute graph, the computer device can determine the attribute graph with the lowest execution cost or the highest overall similarity as the second attribute graph. The overall similarity includes node similarity and edge similarity, which can be a weighted average or mean of the two, and the specifics are not limited here.
[0022] In this application, when determining the second attribute graph similar to the first attribute graph, it can be determined not only based on node similarity or edge similarity, but also by combining node similarity and edge similarity, thus enriching the implementation methods of the technical solution of this application. In the latter technical solution, the screening conditions are more stringent, making the determined second attribute graph more likely to meet the requirements, further improving the accuracy of the technical solution of this application.
[0023] In one possible implementation of the first aspect, the execution plan of the second attribute graph includes: the execution plan at the connection level corresponding to the cached second attribute graph.
[0024] In this application, the execution plan at the connection relationship level is cached, which reduces caching overhead and improves cache hit rate compared to caching the complete execution plan in traditional solutions.
[0025] A second aspect of this application provides a computer device, including an acquisition unit and a processing unit.
[0026] The acquisition unit is used to acquire a query instruction, which includes at least two first data tables and at least one join relationship.
[0027] The processing unit is configured to: construct a first attribute graph, the first attribute graph including at least two first nodes corresponding one-to-one with at least two first data tables, and at least one first edge corresponding one-to-one with at least one connection relationship; determine a second attribute graph similar to the first attribute graph from a cache based on node similarity and / or edge similarity, the second attribute graph including at least two second nodes corresponding one-to-one with at least two first nodes, and at least one second edge corresponding one-to-one with at least one first edge; and reuse the execution plan of the second attribute graph to process query instructions to obtain query results of the query instructions.
[0028] The computer device is used to execute the method shown in the first aspect or any possible implementation of the first aspect, and its beneficial effects are similar to those of the first aspect or any possible implementation of the first aspect, which will not be repeated here.
[0029] A third aspect of this application provides a computer device including a processor and a memory, wherein the processor stores instructions that, when executed on the processor, implement the method shown in the first aspect or any possible implementation thereof.
[0030] The fourth aspect of this application provides a computer-readable storage medium storing instructions that, when executed on a processor, implement the method shown in the first aspect or any possible implementation thereof.
[0031] The fifth aspect of this application provides a computer program product that, when executed on a processor, implements the method shown in the first aspect or any possible implementation of the first aspect.
[0032] The beneficial effects shown in any of the third to fifth aspects are similar to those of the first aspect or any possible implementation of the first aspect, and will not be repeated here. Attached Figure Description
[0033] Figure 1a A schematic diagram of a system architecture provided for an embodiment of this application;
[0034] Figure 1b Another system architecture diagram provided for an embodiment of this application;
[0035] Figure 2 A flowchart illustrating the cache reuse method provided in this application embodiment;
[0036] Figure 3a A schematic diagram of the first attribute map provided in an embodiment of this application;
[0037] Figure 3bAnother schematic diagram of the first attribute diagram provided in the embodiments of this application;
[0038] Figure 4 A schematic diagram provided for an embodiment of this application;
[0039] Figure 5 A schematic diagram of an execution plan provided for an embodiment of this application;
[0040] Figure 6 Another schematic diagram of the execution plan provided for an embodiment of this application;
[0041] Figure 7 A schematic diagram of the structure of a computer device provided in an embodiment of this application;
[0042] Figure 8 Another schematic diagram of the structure of the computer device provided in the embodiments of this application. Detailed Implementation
[0043] This application provides a cache reuse method and related device. In the cache reuse method, a first attribute graph corresponding to a query instruction is constructed. The at least two first data tables and at least one connection relationship included in the query instruction are converted into at least two first nodes and at least one first edge in the first attribute graph. Then, based on node similarity and / or edge similarity, a second attribute graph similar to the first attribute graph is determined from the cache, and the execution plan of the second attribute graph is reused to process the query instruction, thereby obtaining the query result. In other words, in this application, the textual query instruction is converted into an abstract attribute graph, and the execution plan in the cache is reused based on a similarity graph matching algorithm, thereby improving matching efficiency.
[0044] The embodiments of this application will now be described with reference to the accompanying drawings. Those skilled in the art will recognize that, with technological advancements and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.
[0045] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms are interchangeable where appropriate; this is merely a way of distinguishing objects with the same attributes in the embodiments of this application. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, so that a process, method, system, product, or apparatus that comprises a series of units is not necessarily limited to those units, but may include other units not explicitly listed or inherent to those processes, methods, products, or apparatuses. Additionally, "at least one" means one or more, and "more than one" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or multiple items. For example, at least one of a, b, or c can be expressed as: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.
[0046] First, please refer to Figure 1a and Figure 1b , Figure 1a and Figure 1b These are all schematic diagrams of the system architecture of embodiments of this application.
[0047] The cache reuse method provided in this application is applied to relational databases, including single-machine architectures and distributed architectures. Regardless of the architecture, the cache reuse method provided in this application can be applied.
[0048] like Figure 1a As shown, a standalone architecture refers to a single computer device independently controlling hardware resources such as the central processing unit (CPU), memory, and hard drive. It has advantages such as simple architecture and ease of setup.
[0049] A distributed architecture refers to a system where multiple computer devices are connected via the internet, and these devices may share memory or disk space, or neither. For example, in... Figure 1bIn the illustrated embodiment, the various computer devices do not share memory and disk, and the resulting relational database belongs to the share-nothing model. In this type, data is distributed across multiple nodes, and each node contains different data. For example, in a massively parallel processing (MPP) architecture, hierarchical storage is used, dividing nodes into coordinator nodes (CNs) and data nodes (DNs). CNs are used to obtain query instructions, determine execution plans, and send the execution plans to DNs. DNs are used to process query instructions according to the execution plans and obtain query results.
[0050] It should be noted that the computer equipment mentioned above refers to equipment capable of providing database services, and does not limit the type of computer equipment. In different architectures, the type of computer equipment may be different, such as server equipment, network equipment, terminal equipment, etc., which are not limited here.
[0051] Next, the cache reuse method provided in the embodiments of this application will be described. Please refer to [link / reference]. Figure 2 , Figure 2 This is a flowchart illustrating the cache reuse method provided in an embodiment of this application. Figure 2 As shown, it includes the following steps:
[0052] 201. Obtain a query instruction, which includes at least two first data tables and at least one join relationship.
[0053] Computer devices can obtain SQL query statements input by users, that is, query instructions. A query instruction includes at least two primary data tables and at least one join relationship, indicating the data the user needs. In the query instruction, data tables can be represented by their names, and the join relationship can have various possible join types. Examples include: nested loop join (NL join), merge join, hash join, etc., but specific types are not limited here.
[0054] For example, suppose the user inputs the SQL query "select * from student left join score on true left join course on score.cno=course.cno". Based on this, the computer device can determine that the query instruction includes three primary data tables and two join relationships. The three primary data tables are table student, table score, and table course. The join type between the first two tables is left join, and the join condition is true; the join type between the result of the join of the first two tables and table course is left join, and the join condition is score.cno=course.cno.
[0055] 202. Construct a first attribute graph, which includes at least two first nodes corresponding one-to-one with at least two first data tables, and at least one first edge corresponding one-to-one with at least one connection relationship.
[0056] After receiving a query command, the computer device constructs a first attribute graph based on the query command, abstracting the textual statement into the form of an attribute graph. During the conversion, data tables are used as vertices, and edges are established between data tables with connection relationships. The first attribute graph includes at least two first nodes and at least one first edge. These at least two first nodes correspond one-to-one with the at least two first data tables included in the query command, and the at least one first edge corresponds one-to-one with at least one connection relationship included in the query command.
[0057] The following explanation is illustrated in conjunction with diagrams. Please refer to the diagrams provided. Figure 3a and Figure 3b , Figure 3a and Figure 3b These are all schematic diagrams of the first attribute diagrams provided in the embodiments of this application.
[0058] For example, assuming the query is "select * from student left join score on true left join course on score.cno=course.cno", the computer device can determine that it includes three first data tables and two first edges. The three first data tables are student, score, and course, and the join type for both join relationships is left join. Based on this, the first attribute graph constructed by the computer device is as follows: Figure 3a As shown, it includes three first nodes and two first edges. In Figure 3aIn the illustrated embodiment, an ellipse represents the first node, and a line represents the first side. The three first nodes correspond one-to-one with the three first data tables, and the two first sides correspond one-to-one with the two connection relationships.
[0059] In addition, embodiments of this application also define edge attributes, including the connection type and connection conditions corresponding to the edge. Edge attributes can be obtained from query instructions. For example... Figure 3a As shown, the first node `student` and the first node `score` are connected by the first edge `A`, which is a left join with a condition of `true`. The result of connecting `student` and `score` is then connected to the first node `course` by the first edge `B`, which is also a left join with a condition `score.cno = course.cno`.
[0060] For example, suppose the query is "select * from student, score, course where student.sno = score.sno", and the default join type is set to inner join, with the default join condition being true. Based on this, the computer device can determine that the first attribute graph includes three first data tables and two first edges. The three first data tables are student, score, and course, and the join type for both join relationships is inner join. Based on this, the first attribute graph constructed by the computer device is as follows: Figure 3b As shown, it includes three first nodes and two first edges.
[0061] exist Figure 3b As shown, the first node `student` and the first node `score` are connected by the first edge `C`. The connection type for the first edge `C` is inner join, and the connection condition is `student.sno = score.sno`. The result of connecting the first nodes `student` and `score` is then connected to the first node `course` by the first edge `D`. The connection type for the first edge `D` is left join, and the connection condition is true.
[0062] 203. Based on node similarity and / or edge similarity, determine from the cache a second attribute graph similar to the first attribute graph, the second attribute graph including at least two second nodes corresponding one-to-one with at least two first nodes, and at least one second edge corresponding one-to-one with at least one first edge.
[0063] After converting the query instruction into a first attribute graph, the computer device needs to determine a second attribute graph similar to the first attribute graph from the cache in order to reuse the execution plan of the second attribute graph. Specifically, the computer device determines the second attribute graph based on node similarity and / or edge similarity. If the second attribute graph is similar to the first attribute graph, then the number of second nodes and the number of second edges in the second attribute graph are the same as those in the first attribute graph. That is, the second attribute graph includes at least two second nodes corresponding to at least two first nodes, and at least one second edge corresponding to at least one first edge.
[0064] In practical applications, there are several possible ways for computer devices to determine the second attribute graph. The following sections will explain the possible scenarios.
[0065] First, the computer equipment determines the second attribute graph based on node similarity.
[0066] In this scheme, the computer device performs similarity matching on at least two first nodes in the first attribute graph and nodes in the cached candidate attribute graph set, sequentially from the first node to the last node. The candidate attribute graph set includes at least one attribute graph, and the number of nodes and edges in each attribute graph is the same as the number of first nodes and first edges in the first attribute graph, respectively.
[0067] If there are nodes in the third attribute graph of the candidate attribute graph set that do not meet the node similarity condition, the computer device will stop similarity matching with the third attribute graph, that is, determine that the third attribute graph is dissimilar to the first attribute graph. If at least two third nodes in the fourth attribute graph of the candidate attribute graph set are similar to at least two first nodes one-to-one (that is, the fourth attribute graph and the first attribute graph meet the node similarity condition), then the computer device can determine the second attribute graph based on the fourth attribute graph. It should be noted that the number of fourth attribute graphs is not limited here; a fourth attribute graph refers to one or more attribute graphs in the candidate attribute graph set where at least two third nodes are similar to at least two first nodes one-to-one.
[0068] It is important to note that when performing node similarity matching, the computer device compares at least two first nodes in the first attribute graph with nodes in the candidate attribute graph one by one, from the first node to the last node. Here, the first node refers to the first node in the attribute graph, corresponding to the first data table in the query instruction; the last node refers to the last node in the attribute graph, corresponding to the last data table in the query instruction. For example, corresponding to... Figure 3a In the embodiment shown in 3b, the first node refers to the node student, and the last node refers to the node course.
[0069] For example, suppose the first nodes in the first attribute graph are ordered from first node to last node as first node 1, first node 2, first node 3, first node 4, and first node 5. The third nodes in the fourth attribute graph are ordered from first node to last node as third node A, third node B, third node C, third node D, and third node E. Then, the node similarity matching process proceeds in the following order: "Compare first node 1 with third node A → Compare first node 2 with third node B → Compare first node 3 with third node C → Compare first node 4 with third node D → Compare first node 5 with third node E". During the comparison process, if any node does not meet the node similarity conditions, the comparison with that attribute graph is stopped.
[0070] The node similarity condition is related to the node similarity. There are several possible settings for node similarity, which will be explained below.
[0071] In some alternative implementations, node similarity can be determined based on the size of the attribute graph. The size of the attribute graph includes the size of each node in the attribute graph. For example, node similarity can be determined using Formula 1 as shown below:
[0072]
[0073] Here, size(t1) indicates the size of data table t1, and size(t2) indicates the size of data table t2. In practical applications, the size of a data table can include the number of rows, the number of columns, or the number of elements included in the data table (i.e., the number of rows × the number of columns), and there is no specific limitation here.
[0074] Computer devices can set a threshold for Formula 1. According to the calculation method of Formula 1, the smaller the result, the closer the sizes of the two data tables are, and the higher the node similarity. The threshold can be determined based on historical information or the needs of the actual application; a reasonable range can be chosen. For example, the threshold can be set between 0 and 1. For applications with higher requirements or limited computing power, the threshold can be set smaller.
[0075] In some optional implementations, node similarity can also be determined based on the index definition of the data table. A data table index is a special database structure used to quickly retrieve specific records within a data table, thus accelerating data retrieval. Common index forms include directories. The index definition of a data table includes index fields, the data range defined by the index, etc. When the index definitions of different data tables are similar, the different data tables can be considered similar, meaning they meet the node similarity condition.
[0076] Additionally, it's important to note that a single data table can have one or more index definitions. When determining node similarity based on the index definitions of a data table, all index definitions of two nodes can be compared. When different nodes have similar index definitions, the two nodes can be considered to satisfy the node similarity condition within the scope of similar index definitions. For example, suppose data table 1 includes index 1 and index 2, and data table 2 includes index 3 and index 4, and index 1 and index 3 are similar. Then, when data table 1 applies index 1 and data table 2 applies index 3, data table 1 and data table 2 can be considered similar, meaning the nodes corresponding to data table 1 and the nodes corresponding to data table 2 satisfy the node similarity condition.
[0077] In some alternative implementations, node similarity can also be determined based on both the size of the attribute graph and the index definition. That is, the computer device considers both factors to determine whether different nodes satisfy the node similarity requirement.
[0078] In summary, in this embodiment, when performing similarity matching between at least two first nodes of the first attribute graph and nodes in the candidate attribute graph set, the comparison is performed sequentially from the first node to the last node. If a node does not meet the node similarity condition, the computer device will stop comparing with that attribute graph, that is, it will no longer perform similarity matching on subsequent nodes, thereby narrowing the comparison range of the execution plan, reducing the comparison time, and thus reducing the optimization time of the SQL statement. In addition, the computer device can perform node similarity matching based on various possibilities, enriching the implementation methods and application scenarios of the technical solution of this application.
[0079] It should be noted that the number of fourth attribute graphs that satisfy the node similarity condition with the first attribute graph is not limited in this embodiment; there can be one or more. The computer device determines the second attribute graph differently depending on the number of fourth attribute graphs. If there is only one fourth attribute graph, the computer device determines that fourth attribute graph as the second attribute graph. If there are multiple fourth attribute graphs, the computer device can determine the attribute graph with the lowest execution cost or the highest node similarity as the second attribute graph.
[0080] The execution cost is determined based on the size of the fourth attribute graph. The size of the fourth attribute graph can be determined based on the size of each third node within it. The size of each third node includes the number of rows, columns, or elements in the corresponding data table (i.e., the number of rows × the number of columns), without specific limitations here. The computer device can determine the size of the fourth attribute graph as the average or weighted value of at least two third nodes. The process of determining the execution cost based on the data table size is similar to the traditional method and will not be elaborated upon here.
[0081] Node similarity is determined based on the size of the first attribute graph and the size of the fourth attribute graph, and / or the index definitions of the first and fourth attribute graphs. The specific process has been explained above and will not be repeated here.
[0082] In this embodiment, when there are multiple fourth attribute graphs that satisfy the node similarity condition with nodes in the first attribute graph, the computer device can filter them and select the attribute graph with the lowest execution cost as the second attribute graph. This minimizes the execution cost of the execution plan reused by the computer device, reducing the execution cost of processing query instructions. Alternatively, the computer device can select the attribute graph with the highest node similarity as the second attribute graph, thereby ensuring the similarity between the first and second attribute graphs and improving the accuracy of the matched execution plan. Furthermore, there are multiple possible ways to determine node similarity, enriching the implementation methods of the technical solution of this application and enhancing its flexibility.
[0083] II. The computer device determines the second attribute graph based on edge similarity.
[0084] In this scheme, the computer device performs similarity matching on at least one first edge in the first attribute graph and the edges in the candidate attribute graph set in the cache, sequentially from the first edge to the last edge. The candidate attribute graph set includes at least one attribute graph, and the number of nodes and edges in each attribute graph is the same as the number of first nodes and first edges in the first attribute graph, respectively.
[0085] If there is an edge in the fifth attribute graph of the candidate attribute graph set that does not satisfy the edge similarity condition, the computer device will stop similarity matching with the fifth attribute graph, that is, determine that the sixth attribute graph is dissimilar to the first attribute graph. If at least one third edge in the sixth attribute graph of the candidate attribute graph set is similar to at least one first edge (that is, the sixth attribute graph and the first attribute graph satisfy the edge similarity condition), then the computer device can determine the second attribute graph based on the sixth attribute graph. It should be noted that the number of sixth attribute graphs is not limited here; a sixth attribute graph refers to one or more attribute graphs in the candidate attribute graph set whose at least one third edge is similar to at least one first edge.
[0086] It should be noted that during edge similarity matching, the computer device compares at least one edge in the first attribute graph with each edge in the candidate attribute graph, from the first edge to the last edge. The first edge refers to the first edge in the attribute graph, located between the first node and the next node in the attribute graph, corresponding to the first connection in the query command. The last edge refers to the last edge in the attribute graph, corresponding to the first connection in the query command. For example, corresponding to... Figure 3aIn the embodiment shown, the first side refers to the first side A, because Figure 3a Since there are only two edges, the next edge after the first edge A, the first edge B, is the tail edge.
[0087] For example, suppose the first edges in the first attribute graph are ordered from first edge to last edge as edge 1, edge 2, edge 3, and edge 4. The third edges in the sixth attribute graph are ordered from first edge to last edge as edge A, edge B, edge C, and edge D. Then, during edge similarity matching, the process proceeds in the order of "compare edge 1 with edge A → compare edge 2 with edge B → compare edge 3 with edge C → compare edge 4 with edge D". During the comparison, if any edge does not meet the edge similarity condition, the comparison with that attribute graph is stopped.
[0088] In the embodiments of this application, there are multiple possible ways to determine whether different edges satisfy the edge similarity condition, which will be described below.
[0089] In some alternative implementations, the satisfaction of the edge similarity condition can be determined based on the connection type indicated by the edge. Figure 3a and Figure 3b The illustrated embodiment describes various possible connection types, which will not be elaborated upon here. Optionally, two edges can be set to have the same connection type, meaning that the edge similarity is 100% to be considered similar; alternatively, an edge similarity threshold can be set, comparing the similarity of two edges, and considering the two edges similar as long as the edge similarity is greater than the threshold. Specific limitations are not specified here.
[0090] In some alternative implementations, the satisfaction of the edge similarity condition can be determined based on the hit rate of the connection conditions indicated by the edges. For example, edge similarity can be determined using Formula 2 as shown below:
[0091]
[0092] Here, selectivity(condition1) represents the hit rate of condition 1, and selectivity(condition2) represents the hit rate of condition 2. The computer device can set a threshold for Formula 2. According to the calculation method of Formula 2, the smaller the result, the closer the hit rates of the connection conditions indicated by the two edges are, and the higher the edge similarity. The threshold can be determined based on historical information or the needs of the actual application; a reasonable range can be selected. For example, the threshold can be set between 0 and 1. For applications with higher requirements or limited computing power, the threshold can be set smaller.
[0093] In some alternative implementations, the edge similarity condition can also be determined based on the hit rate of the edge indication connection type and the edge indication connection condition. When both the edge indication connection type and the edge indication connection condition hit rate are similar, the edges are determined to be similar.
[0094] In summary, in this embodiment, when performing similarity matching between at least two first edges of the first attribute graph and edges in the candidate attribute graph set, the comparison is performed sequentially from the first edge to the last edge. If an edge does not meet the edge similarity condition, the computer device stops comparing with that attribute graph, meaning it no longer performs similarity matching on subsequent edges. This narrows the comparison range of the execution plan, reduces comparison time, and consequently reduces the optimization time of the SQL statement. Furthermore, the computer device can use various possible criteria for edge similarity matching, enriching the implementation methods and application scenarios of the technical solution in this application.
[0095] It should be noted that the number of sixth attribute graphs that satisfy the edge similarity condition with the first attribute graph is not limited in this embodiment; there can be one or more. The computer device determines the second attribute graph differently depending on the number of sixth attribute graphs. If there is only one sixth attribute graph, the computer device determines that sixth attribute graph as the second attribute graph. If there are multiple sixth attribute graphs, the computer device can determine the attribute graph with the lowest execution cost or the highest edge similarity as the second attribute graph.
[0096] The execution cost mentioned here is determined based on the size of the sixth attribute graph, similar to the determination of the execution cost of the fourth attribute graph mentioned earlier, and will not be repeated here. Edge similarity is determined based on the hit rate of the connection conditions indicated by the first edge of the first attribute graph and the hit rate of the connection conditions indicated by the third edge of the corresponding sixth attribute graph, and / or, the connection relationship type indicated by the first edge of the first attribute graph and the connection relationship type indicated by the third edge of the corresponding third attribute graph. The specific process has been explained earlier and will not be repeated here.
[0097] In this embodiment, when there are multiple sixth attribute graphs that satisfy the edge similarity condition with the edges in the first attribute graph, the computer device can filter them and select the attribute graph with the lowest execution cost as the second attribute graph. This minimizes the execution cost of the execution plan reused by the computer device and reduces the execution cost of processing query instructions. Alternatively, the computer device can select the attribute graph with the highest edge similarity as the second attribute graph, thereby ensuring the similarity between the first and second attribute graphs and improving the accuracy of the matched execution plan. Furthermore, there are multiple possible ways to determine edge similarity, enriching the implementation methods of the technical solution of this application and enhancing its flexibility.
[0098] Third, the computer equipment determines the second attribute graph based on node similarity and edge similarity.
[0099] In this scheme, the computer device can perform node and edge similarity matching with at least one attribute graph in the cached attribute graph set, starting from the first node, in a "node-edge-node" order. The node similarity matching and edge similarity matching are similar to the previous implementation method and will not be repeated here.
[0100] It is important to note that in this implementation, similarity comparison is performed alternately by comparing nodes and edges. During the comparison process, if an attribute graph in the candidate attribute graph set does not meet the node similarity or edge similarity conditions, the computer device stops comparing it with that attribute graph. In other words, the attribute graph selected by the computer device as similar to the first attribute graph is similar not only to the nodes of the first attribute graph but also to its edges. If the computer device selects multiple attribute graphs similar to the first attribute graph, it can determine the attribute graph with the lowest execution cost or the highest overall similarity as the second attribute graph. The overall similarity includes node similarity and edge similarity, which can be a weighted value or average of the two, etc., and is not specifically limited here.
[0101] For clarity, please refer to Figure 4 , Figure 4 This is a schematic diagram provided for an embodiment of this application. For example, it is assumed that... Figure 4 Attribute diagram 1 in the diagram is the first attribute diagram, and the attributes are... Figure 2 Each attribute graph in the candidate attribute graph set is a single attribute graph.
[0102] like Figure 4 As shown, attribute graph 1 includes nodes 1 to 4 and edges A to C; attributes Figure 2 Includes nodes 5 to 8, and edges D to F. Match attribute graph 1 and attributes based on node similarity and edge similarity. Figure 2 The comparison is performed in the following order: "Compare node 1 with node 5 → Compare edge A with edge D → Compare node 2 with node 6 → Compare edge B with edge E → Compare node 3 with node 7 → Compare edge C with edge F → Compare node 4 with node 8". During the comparison process, if any node or edge does not meet the node similarity condition, the comparison is stopped.
[0103] In this embodiment, when determining the second attribute graph similar to the first attribute graph, it can be determined not only based on node similarity or edge similarity, but also by combining node similarity and edge similarity, thus enriching the implementation methods of the technical solution of this application. In the latter technical solution, the screening conditions are more stringent, making the determined second attribute graph more likely to meet the requirements, further improving the accuracy of the technical solution of this application.
[0104] 204. Reuse the execution plan of the second attribute graph to process the query command and obtain the query result of the query command.
[0105] After determining the second attribute graph, the computer device can process the query instruction based on the execution plan of the second attribute graph to obtain the query result. The execution plan of the second attribute graph includes: a cached execution plan at the join relationship level corresponding to the second attribute graph. That is, the cached plan is the operator-level execution plan, not the complete execution plan.
[0106] Based on this, it can be seen that in this embodiment of the application, the execution plan at the connection relationship level is cached. Compared with the traditional solution of caching the complete execution plan, the caching overhead is reduced and the cache hit rate is improved.
[0107] In summary, in this embodiment, the textual query instruction is converted into an abstract first attribute graph. Then, based on node similarity and / or edge similarity, the first attribute graph is matched with cached attribute graphs to determine a second similar graph that matches the first similar graph. The execution plan of the second attribute graph is then reused to process the query instruction to obtain the query results. Compared to traditional text similarity matching algorithms, this improves matching efficiency.
[0108] It should also be noted that users are unaware of the similarity matching process performed by the aforementioned computer devices; they simply input a query command and obtain the results. In some optional implementations, users can input query commands and obtain results through an application programming interface (API), but this is not limited here.
[0109] In some optional implementations, an API for querying can also be made available to users. Information that users can query includes the cached plan status, cached plan hit rate, etc. The cached plan status indicates which queries in the input query statements hit the cached plan, and what kind of cached plan was hit. The hit rate refers to the proportion of queries that hit the cached plan among multiple input queries. The plan referred to here has the same meaning as the execution plan mentioned earlier. For example, in an MMP architecture, data is stored hierarchically, and CN nodes have the ability to cache execution plans; users can query the cached plan status via the API.
[0110] In some optional implementations, the cache reuse method provided in this application can also be provided as part of the database system in the form of a software algorithm functional module. Users can configure parameters such as whether to enable planned caching (i.e., whether to apply the cache reuse plan provided in this application), and control parameters such as cache size and cache join level (which can be simply understood as the number of join tables), etc., which are not specifically limited here.
[0111] The process of determining similar attribute graphs by a computer device in this application embodiment will be further explained below with reference to examples. In this application embodiment, an execution plan reuse technique for similar attribute graph calculation can be introduced into the dynamic programming-based connection path search algorithm. By caching the execution plan at the operator level, the attribute graph corresponding to the query instruction is then matched with the cached attribute graph for similarity, and the cached execution plan is reused.
[0112] For simplicity, the symbol "->" will be used below to represent the edge connecting two nodes in the attribute graph. It's important to note that this arrow symbol does not have directional meaning; it only indicates that there is an edge connecting the nodes. The arrow symbol is used simply to more intuitively represent the similarity subgraph matching process in the join path search. For two nodes A and B to be similar, it is represented as `node_similiar(A, B)`. The set of all nodes similar to node A is represented as `{A, [B, C, D]}`, meaning that nodes B, C, and D are all similar to node A. In other words, nodes A, B, C, and D are mutually similar, but their similarity may differ. For two edges e1 and e2 to be similar, it is defined as `edge_similiar(e1, e2)`. The symbol `graph_similar` is introduced to indicate that two attribute graphs are similar. For example, `graph_similar(({a->b->c},{1->2->3}), true, 3)` means that attribute graph a->b->c is similar to attribute graph 1->2->3, and the similarity connection level is 3, that is, the number of nodes is 3.
[0113] For example, suppose the user-input query is converted into a first attribute graph, input_graph: 1->2->3->4. Simultaneously, the database system caches the following three execution plans for attribute graphs: graph1: a1->b1->c1->d1, graph2: 2->b2->c2->d2, and graph3: a3->b3->c3->d3. Assume that each edge of these three attribute graphs satisfies the edge similarity condition with each edge of the first attribute graph.
[0114] The computer device performs similarity matching between the nodes in the first attribute graph and the nodes in the three attribute graphs in order from the first node to the last node.
[0115] Suppose that for attribute graph graph2, the computer device determines the following node similarities: node_similiar(a2, [1, 2]), node_similiar(c2, 33), and node_similiar(d2, 4). That is, in attribute graph graph2, nodes 1 and 2 in the first attribute graph are similar to the same node, resulting in no subgraph in attribute graph graph2 similar to 1->2. Therefore, the computer device stops similarity matching between the first attribute graph and attribute graph graph2.
[0116] Suppose that for attribute graph graph1, the computer determines that the nodes are similar, i.e., node_similiar(a1, 1), node_similiar(b1, 2), node_similiar(c1, 3), and node_similiar(d1, 4). Suppose that for attribute graph graph3, the computer determines that the nodes are similar, i.e., node_similiar(a3, 1), node_similiar(b3, 2), node_similiar(c3, 3), and node_similiar(d3, 4). Then, in the four connection levels included in the first attribute graph, there are similar subgraphs in both attribute graphs graph1 and graph3.
[0117] Furthermore, in the process of determining whether nodes are similar and whether edges between nodes are similar in attribute graphs graph1 and graph3, the similar subgraph sets shown in Tables 1 and 2 below can be obtained.
[0118] Table 1
[0119]
[0120] Table 2
[0121]
[0122] Table 1 shows the similarity between attribute graph graph1 and the first attribute graph input_graph, and Table 2 shows the similarity between attribute graph graph3 and the first attribute graph input_graph.
[0123] The computer device can find the execution plans for attribute graphs graph1 and graph3 in the cache. For example, as shown... Figure 5 As shown, Figure 5 The graph on the left represents the execution plan of the attribute graph graph1. Figure 5 The graph on the right represents the execution plan of the attribute graph graph3.
[0124] like Figure 5 As shown, the execution plan of attribute graph graph1 includes: node a1 and node b1 are joined using an NL join to obtain result 1. Result 1 and node c1 are joined using a merge join to obtain result 2. Result 2 and node d1 are joined using a hash join to obtain the final query result.
[0125] like Figure 5 As shown, the execution plan of attribute graph graph3 includes: a hash join between node a3 and node b3 to obtain result 4; an NL join between result 4 and node c3 to obtain result 5; and a hash join between result 5 and node d3 to obtain the final query result.
[0126] Optionally, the computer device selects the execution plan with the lower execution cost from attribute graphs graph1 and graph3 for reuse. Assuming that the execution plan of attribute graph3 is smaller, the execution plan of the first attribute graph, input_graph, can be obtained as follows: Figure 6 As shown. Specifically, node 1 and node 2 are hashed together to obtain the first result. The first result is then hashed together with node 3 to obtain the second result. The second result is then hashed together with node 4 to obtain the final query result.
[0127] Please refer to the following. Figure 7 , Figure 7 A schematic diagram of the structure of a computer device provided in an embodiment of this application. For example... Figure 7 As shown, the computer device 700 includes an acquisition unit 701 and a processing unit 702.
[0128] In some optional implementations, the acquisition unit 701 is used to acquire a query instruction, which includes at least two first data tables and at least one connection relationship.
[0129] Processing unit 702 is configured to: construct a first attribute graph, the first attribute graph including at least two first nodes corresponding one-to-one with at least two first data tables, and at least one first edge corresponding one-to-one with at least one connection relationship; determine a second attribute graph similar to the first attribute graph from a cache based on node similarity and / or edge similarity, the second attribute graph including at least two second nodes corresponding one-to-one with at least two first nodes, and at least one second edge corresponding one-to-one with at least one first edge; and reuse the execution plan of the second attribute graph to process a query instruction to obtain the query result of the query instruction.
[0130] In some optional implementations, processing unit 702 is specifically configured to: sequentially perform similarity matching between at least two first nodes and nodes in a cached candidate attribute graph set, in order from the first node to the last node, wherein the candidate attribute graph set includes at least one attribute graph. If there are nodes in the third attribute graph of the candidate attribute graph set that do not meet the node similarity condition, then the similarity matching with the third attribute graph is stopped. If at least two third nodes in the fourth attribute graph of the candidate attribute graph set are similar to at least two first nodes one by one, then a second attribute graph is determined based on the fourth attribute graph.
[0131] In some optional implementations, the processing unit 702 is specifically used to: determine the attribute graph with the lowest execution cost or the highest node similarity in the fourth attribute graph as the second attribute graph.
[0132] In some alternative implementations, the execution cost is determined based on the size of the fourth attribute graph. Node similarity is determined based on the sizes of the first and fourth attribute graphs, and / or the index definitions of the first and fourth attribute graphs.
[0133] In some optional implementations, processing unit 702 is specifically configured to: sequentially perform similarity matching between at least one first edge and edges in a cached candidate attribute graph set, from the first edge to the last edge, wherein the candidate attribute graph set includes at least one attribute graph. If there is an edge in the fifth attribute graph of the candidate attribute graph set that does not satisfy the edge similarity condition, then the similarity matching with the fourth attribute graph is stopped. If at least one third edge in the sixth attribute graph of the candidate attribute graph set is similar to at least one first edge, then a second attribute graph is determined based on the sixth attribute graph.
[0134] In some optional implementations, the processing unit 702 is specifically used to: determine the attribute graph with the lowest execution cost or the highest edge similarity in the sixth attribute graph as the second attribute graph.
[0135] In some alternative implementations, edge similarity is determined based on the hit rate of connection conditions indicated by the first edge of the first attribute graph and the hit rate of connection conditions indicated by the third edge of the corresponding sixth attribute graph, and / or the connection relationship type indicated by the first edge of the first attribute graph and the connection relationship type indicated by the third edge of the corresponding third attribute graph.
[0136] In some optional implementations, the execution plan for the second attribute graph includes: an execution plan at the connection level corresponding to the cached second attribute graph.
[0137] Computer device 700 is used to perform the aforementioned Figures 1a to 6 The operations performed by the computer device in the illustrated embodiment will not be described in detail here.
[0138] Please refer to the following. Figure 8 , Figure 8 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. The computer device 800 includes a processor 801 and a memory 802, wherein the memory 802 stores one or more application programs or data.
[0139] The memory 802 can be volatile or persistent storage. The program stored in the memory 802 can include one or more modules, each of which can be used to execute a series of operations performed by the computer device 800. Furthermore, the processor 801 can communicate with the memory 802 and execute a series of instructions stored in the memory 802 on the computer device 800. The processor 801 can be a central processing unit (CPU), a single-core processor, or other types of processors, such as a dual-core processor; specific limitations are not specified here.
[0140] Computer device 800 may also include one or more communication interfaces 803, and one or more operating systems, such as Windows Server. TM Mac OS X TM Unix TM Linux TM FreeBSD TM wait.
[0141] The computer device 800 can perform the aforementioned... Figures 1a to 6 The operations performed by the computer device in the illustrated embodiment will not be described in detail here.
[0142] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0143] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between apparatuses or units through some interfaces, and may be electrical, mechanical, or other forms.
[0144] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0145] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0146] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A method of cache multiplexing, the method comprising: include: Obtain a query instruction, wherein the query instruction includes at least two first data tables and at least one join relationship; Construct a first attribute graph, which includes at least two first nodes corresponding one-to-one with the at least two first data tables, and at least one first edge corresponding one-to-one with the at least one connection relationship; Based on node similarity and / or edge similarity, a second attribute graph similar to the first attribute graph is determined from the cache. The second attribute graph includes at least two second nodes that correspond one-to-one with the at least two first nodes, and at least one second edge that corresponds one-to-one with the at least one first edge. The execution plan of the second attribute graph is reused to process the query instruction in order to obtain the query result of the query instruction; The step of determining a second attribute graph similar to the first attribute graph from the cache based on node similarity and / or edge similarity includes: Following the order from the first node to the last node, the at least two first nodes are sequentially matched with nodes in the candidate attribute graph set in the cache to determine the second attribute graph that is similar to the first attribute graph. The candidate attribute graph set includes at least one attribute graph; and / or, Following the order from the first edge to the last edge, the at least one first edge is sequentially matched with the edges in the candidate attribute graph set in the cache to determine the second attribute graph that is similar to the first attribute graph.
2. The method of claim 1, wherein, The step of sequentially matching at least two first nodes with nodes in the candidate attribute graph set in the cache, from the first node to the last node, to determine the second attribute graph similar to the first attribute graph includes: If there are nodes in the third attribute graph of the candidate attribute graph set that do not meet the node similarity condition, then the similarity matching with the third attribute graph is stopped. If at least two third nodes in the fourth attribute graph of the candidate attribute graph set are similar to the at least two first nodes, then the second attribute graph is determined based on the fourth attribute graph.
3. The method of claim 2, wherein, Determining the second attribute map based on the fourth attribute map includes: The attribute graph with the lowest execution cost or the highest node similarity in the fourth attribute graph is determined as the second attribute graph.
4. The method of claim 3, wherein, The execution cost is determined based on the size of the fourth attribute graph; The node similarity is determined based on the size of the first attribute graph and the size of the fourth attribute graph, and / or the index definition of the first attribute graph and the index definition of the fourth attribute graph.
5. The method of claim 1, wherein, The step of sequentially matching at least one first edge with edges in the candidate attribute graph set in the cache, from the first edge to the last edge, to determine the second attribute graph similar to the first attribute graph includes: If there is an edge in the fifth attribute graph of the candidate attribute graph set that does not satisfy the edge similarity condition, then the similarity matching with the fifth attribute graph is stopped. If at least one third edge in the sixth attribute graph of the candidate attribute graph set is similar to at least one first edge, then the second attribute graph is determined based on the sixth attribute graph.
6. The method of claim 5, wherein, Determining the second attribute map based on the sixth attribute map includes: The attribute graph with the lowest execution cost or the highest edge similarity in the sixth attribute graph is determined as the second attribute graph.
7. The method of claim 6, wherein, The edge similarity is determined based on the hit rate of the connection conditions indicated by the first edge corresponding to the first attribute graph and the hit rate of the connection conditions indicated by the third edge corresponding to the sixth attribute graph, and / or the connection relationship type indicated by the first edge corresponding to the first attribute graph and the connection relationship type indicated by the third edge corresponding to the sixth attribute graph.
8. The method according to any one of claims 1 to 7, characterized in that, The execution plan for the second attribute graph includes: the cached execution plan at the connection level corresponding to the second attribute graph.
9. A computer device, comprising: include: An acquisition unit is used to acquire a query instruction, the query instruction including at least two first data tables and at least one connection relationship; The processing unit is configured to construct a first attribute graph, the first attribute graph including at least two first nodes corresponding one-to-one with the at least two first data tables, and at least one first edge corresponding one-to-one with the at least one connection relationship; The processing unit is further configured to determine a second attribute graph similar to the first attribute graph from the cache based on node similarity and / or edge similarity. The second attribute graph includes at least two second nodes that correspond one-to-one with the at least two first nodes, and at least one second edge that corresponds one-to-one with the at least one first edge. The processing unit is further configured to reuse the execution plan of the second attribute graph to process the query instruction, so as to obtain the query result of the query instruction; the processing unit is specifically configured to: Following the order from the first node to the last node, the at least two first nodes are sequentially matched with nodes in the candidate attribute graph set in the cache to determine the second attribute graph that is similar to the first attribute graph. The candidate attribute graph set includes at least one attribute graph; and / or, Following the order from the first edge to the last edge, the at least one first edge is sequentially matched with the edges in the candidate attribute graph set in the cache to determine the second attribute graph that is similar to the first attribute graph.
10. The computer device of claim 9, wherein, The processing unit is specifically used for: If there are nodes in the third attribute graph of the candidate attribute graph set that do not meet the node similarity condition, then the similarity matching with the third attribute graph is stopped. If at least two third nodes in the fourth attribute graph of the candidate attribute graph set are similar to at least two first nodes, then the second attribute graph is determined based on the fourth attribute graph.
11. The computer device of claim 10, wherein, The processing unit is specifically used to: determine the attribute graph with the lowest execution cost or the highest node similarity in the fourth attribute graph as the second attribute graph.
12. The computer device of claim 11, wherein, The execution cost is determined based on the size of the fourth attribute graph; The node similarity is determined based on the size of the first attribute graph and the size of the fourth attribute graph, and / or the index definition of the first attribute graph and the index definition of the fourth attribute graph.
13. The computer device of claim 9, wherein, The processing unit is specifically used for: If there is an edge in the fifth attribute graph of the candidate attribute graph set that does not satisfy the edge similarity condition, then the similarity matching with the fifth attribute graph is stopped. If at least one third edge in the sixth attribute graph of the candidate attribute graph set is similar to at least one first edge, then the second attribute graph is determined based on the sixth attribute graph.
14. The computer device of claim 13, wherein, The processing unit is specifically used to: determine the attribute graph with the lowest execution cost or the highest edge similarity in the sixth attribute graph as the second attribute graph.
15. The computer device of claim 13, wherein, Edge similarity is determined based on the hit rate of the connection conditions indicated by the first edge corresponding to the first attribute graph and the hit rate of the connection conditions indicated by the third edge corresponding to the sixth attribute graph, and / or the connection relationship type indicated by the first edge corresponding to the first attribute graph and the connection relationship type indicated by the third edge corresponding to the sixth attribute graph.
16. The computer device of any one of claims 9-15, wherein, The execution plan for the second attribute graph includes: the execution plan at the connection level corresponding to the cached second attribute graph.
17. A computer device, comprising: include: Memory and processor; The processor stores instructions that, when executed on the processor, implement the method of any one of claims 1 to 8.
18. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed on a processor, implement the method of any one of claims 1 to 8.