A database table join optimization method and apparatus, computing device, and storage medium

By abstracting the database table join problem into a directed graph model and using graph convolutional networks and transformer models for feature extraction and path prediction, the problem of low query optimization efficiency in large-scale database table joins is solved, and optimal path selection under polynomial time complexity is achieved.

CN116049225BActive Publication Date: 2026-04-07CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-28
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

Existing technologies, when performing large-scale database table joins, suffer from high time complexity in dynamic programming algorithms and the tendency of genetic algorithms to get trapped in local optima, failing to find the global optimum, resulting in low query optimization efficiency.

Method used

The database table join problem is abstracted into a directed graph model. Graph convolutional networks are used for feature extraction, and a transformer model is combined for path prediction to achieve optimal path selection.

Benefits of technology

The optimal path selection is achieved within polynomial time complexity, improving query optimization efficiency, avoiding getting trapped in local optima, and enhancing database query performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116049225B_ABST
    Figure CN116049225B_ABST
Patent Text Reader

Abstract

The application discloses a database table connection optimization method and device, computing equipment and a storage medium, and the method comprises the steps of: constructing a directed graph model according to table data to be connected and a database cost model; determining a corresponding feature matrix and an adjacency matrix according to the directed graph model, performing feature extraction on the feature matrix and the adjacency matrix through a graph convolution network to obtain target feature data; inputting the target feature data into a transformer model to predict a node path in the directed graph model, and determining a table connection order according to the node path. The application abstracts a database table connection problem into a sequence prediction problem based on a directed graph model, introduces deep learning into the database table connection, fully utilizes advantages such as spatial features and node representation characteristics, and combines the graph convolution network with the transformer model to complete node path prediction within a polynomial time complexity, thereby making up for the shortcomings of a genetic algorithm in the prior art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and specifically to a database table join optimization method, apparatus, computing device, and storage medium. Background Technology

[0002] In relational databases, each entity has its own table, and all attributes are fields in that table. Tables are joined together based on their join fields. Therefore, table joins are a core issue in relational databases. Optimizing table joins is a significant research area in database technology. The order of table joins is a crucial factor affecting query performance, as it significantly reduces the size of temporary results. Consequently, most query optimizers focus heavily on join order. Based on relational algebra theory, natural joins satisfy the associative law. Finding the least costly join method for equivalent computations has become a hot research topic in databases. Performing a natural join on N tables is a non-deterministic polynomial hard (NP-hard) problem. When N becomes very large, it incurs costs that the database cannot afford. Therefore, controlling the cost within an acceptable range when N is large is a pressing technical problem to be solved.

[0003] In existing technologies, when the value of N is relatively large, genetic algorithms and dynamic programming algorithms are introduced into the database system to solve the connection optimization problem. Genetic algorithms help solve the problem of connection space expansion by limiting the search range to a small range, while dynamic programming algorithms need to traverse every path in the search space.

[0004] However, both dynamic programming and genetic algorithms estimate costs using cost models, failing to fully utilize node information and Euclidean space information. Furthermore, the time complexity of dynamic programming is exponential, while genetic algorithms, although their speed can be improved by controlling parameters, are prone to getting stuck in local optima for large-scale optimization problems and cannot find the global optimum. Summary of the Invention

[0005] In view of the above problems, the present invention is proposed to provide a database table join optimization method, apparatus, computing device and storage medium that overcomes or at least partially solves the above problems.

[0006] According to one aspect of the present invention, a database table join optimization method is provided, comprising:

[0007] Obtain the data of the table to be joined, and construct a directed graph model based on the data of the table to be joined and the database cost model;

[0008] Based on the directed graph model, the corresponding feature matrix and adjacency matrix are determined. The feature matrix and adjacency matrix are then used to extract features through a graph convolutional network to obtain target feature data.

[0009] The target feature data is input into the transformer model, and the node paths in the directed graph model are predicted by the transformer model. The table connection order is determined based on the node paths.

[0010] According to another aspect of the present invention, a database table join optimization apparatus is provided, comprising:

[0011] The model building module is used to obtain the data of the tables to be joined and to build a directed graph model based on the data of the tables to be joined and the database cost model.

[0012] The feature extraction module is used to determine the corresponding feature matrix and adjacency matrix based on the directed graph model, and to extract the target feature data by using the feature matrix and adjacency matrix through a graph convolutional network.

[0013] The processing module is used to input the target feature data into the transformer model, predict the node paths in the directed graph model through the transformer model, and determine the table connection order based on the node paths.

[0014] According to another aspect of the present invention, a computing device is provided, comprising: a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other via the communication bus;

[0015] The memory is used to store at least one executable instruction, which causes the processor to perform the operation corresponding to the above-described database table join optimization method.

[0016] According to another aspect of the present invention, a computer storage medium is provided, the storage medium storing at least one executable instruction that causes a processor to perform an operation corresponding to the database table join optimization method described above.

[0017] According to a database table join optimization method, apparatus, computing device, and storage medium of the present invention, the following steps are taken: First, data of the tables to be joined is acquired. A directed graph model is constructed based on the data and a database cost model. The corresponding feature matrix and adjacency matrix are determined based on the directed graph model. The feature matrix and adjacency matrix are then used to extract features through a graph convolutional network to obtain target feature data. This target feature data is input into a transformer model, which predicts the node paths in the directed graph model. The table join order is then determined based on these node paths. This invention abstracts the database table join problem into a sequence prediction problem based on a directed graph model. Spatial feature extraction is performed through a graph convolutional network, and selection decisions are made through a transformer model to predict the node paths in the directed graph model, achieving optimal path selection. Deep learning is introduced into database table joins, fully utilizing the advantages of spatial features and node representation characteristics. The combination of graph convolutional networks and transformer models can complete node path prediction within polynomial time complexity, overcoming the shortcomings of existing genetic algorithms.

[0018] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and in order to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description

[0019] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:

[0020] Figure 1 The flowchart of a database table join optimization method provided by an embodiment of the present invention is shown.

[0021] Figure 2 This diagram illustrates the GCN network feature extraction process provided in an embodiment of the present invention.

[0022] Figure 3 A schematic diagram of the feature matrix provided in an embodiment of the present invention is shown;

[0023] Figure 4 A schematic diagram of the network structure provided in an embodiment of the present invention is shown;

[0024] Figure 5a This illustration shows the prediction process of the transformer model provided in an embodiment of the present invention. Figure 1 ;

[0025] Figure 5b This illustration shows the prediction process of the transformer model provided in an embodiment of the present invention. Figure 2 ;

[0026] Figure 6 This diagram illustrates the structure of a database table join optimization device according to an embodiment of the present invention.

[0027] Figure 7 A schematic diagram of the structure of a computing device provided in an embodiment of the present invention is shown. Detailed Implementation

[0028] Exemplary embodiments of the invention will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this invention will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.

[0029] Figure 1 A flowchart of an embodiment of a database table join optimization method according to the present invention is shown, as follows: Figure 1 As shown, the method includes the following steps:

[0030] Step S110: Obtain the data of the table to be joined, and construct a directed graph model based on the data of the table to be joined and the database cost model.

[0031] In an optional approach, step S110 further includes: inputting the data of the tables to be joined into the database cost model, using the database cost model to obtain the cost information between the data of the tables to be joined; using the data of the tables to be joined as nodes, setting the edges and directions between each node according to the cost information between the data of the tables to be joined, and constructing a directed graph model.

[0032] In this embodiment, the optimal table join order task is abstracted into an optimal path selection problem based on a directed graph model. Specifically, the join cost of the tables is abstracted into a directed graph model with tables as nodes and join costs as edges. The optimal table join problem is abstracted into a directed graph model, and the database cost model and the data of the tables to be joined are used for vectorization representation. The node and edge content in the directed graph model are represented as vector structures to facilitate deep learning processing and representation of node information and Euclidean space information of the graph when the Graph Convolution Network (GCN) performs spatial feature extraction.

[0033] Specifically, suppose there are ten tables (A, B, C, D, E, F, G, H, I, J) to be joined. The data from these ten tables is input into the database cost model to obtain the cost information between the joined tables. ij Let e(i,j) represent the cost from table i to table j; define G(V,E) as a directed graph, where V represents the set of nodes (A, B, ..., J), E represents the set of edges, and e(i,j) represents the cost from node i to j. ij S = (v1, v2, ..., v n ) represents the final set of table join order.

[0034] Step S120: Determine the corresponding feature matrix and adjacency matrix based on the directed graph model, and extract the features from the feature matrix and adjacency matrix through a graph convolutional network to obtain the target feature data.

[0035] In an optional approach, step S120 further includes: obtaining table information of each node in the directed graph model, determining the node characteristics of each node using the table information of each node, determining the feature matrix based on the node characteristics; determining the graph structure characteristics using the cost information between the data to be joined and the table sequence number of the data to be joined, and determining the adjacency matrix based on the graph structure characteristics.

[0036] In one alternative approach, the table information includes one or more of the following: the table sequence number, number of rows, number of columns, and table size in bytes of the table data to be joined.

[0037] In an alternative approach, the method further includes normalizing the feature matrix and the adjacency matrix.

[0038] In this embodiment, spatial features are extracted based on Graph Convolutional Network (GCN), and the optimal node path is selected through the Transformer model. Deep learning is introduced into the field of database connectivity, making full use of the advantages of spatial features and node representation characteristics. Before building the Transformer model, the sequence data needs to be converted into word vector data.

[0039] Therefore, after defining the directed graph, it is necessary to vectorize the data in the tables to be joined, representing the nodes and edges in the directed graph model as vector structures. First, the feature matrix X and adjacency matrix A are determined using GCN. Specifically, Figure 2 This is a schematic diagram of the feature extraction process in a GCN network, as shown below. Figure 2As shown, the input data consists of the feature matrix and the adjacency matrix, which are processed through hidden layer 1, hidden layer 2, and a rectified linear unit (ReLU). The output is the processed data. Figure 2 The rectangle in the middle represents the feature data. GCN is a method for feature extraction from the graph model structure, which can obtain an embedded representation of the graph. The input of GCN is the feature matrix X and the adjacency matrix A. The feature matrix X and the adjacency matrix A reflect the node features and the graph structure features, respectively. Through the GCN network, features are combined and extracted to obtain the target feature data corresponding to the directed graph model. Assuming there are N tables to be joined, the target feature data can be (N, 512) dimensional feature data. The target feature data can fully reflect Euclidean space information, node relationships and node features. The target feature data can be connected to the downstream transformer model for node path selection.

[0040] Figure 3 A schematic diagram of the feature matrix, such as Figure 3 As shown, firstly, determining the feature matrix requires obtaining the table information of each node in the directed graph model. Among these, the number of rows, columns, table size in bytes, and table sequence number of the tables to be joined are the feature information closely related to the table join. Therefore, the table information should include at least one or more of the following: the table sequence number, number of rows, number of columns, and table size of the tables to be joined. These four pieces of table information characterize the node characteristics of each node, and the feature matrix is ​​determined based on these node characteristics. Specifically, a 512-bit vector is used to represent the node characteristics, with each value occupying 128 bits. Assuming there are N tables to be joined, the dimension of X is (N, 512).

[0041] Secondly, the adjacency matrix A can reflect the cost characteristics and node relationship characteristics between the data in the tables to be joined. Specifically, the graph structure characteristics are determined using the cost information between the data in the tables to be joined and the table sequence numbers of the data in the tables to be joined. The dimension is (N, N), and its value is determined by (id). i Cost ij id j ) representation.

[0042] After determining the feature matrix X and the adjacency matrix A, the values ​​in the two-dimensional matrices X and A can be normalized, and the distance values ​​can be normalized by z-value normalization, which facilitates feature combination and extraction through the GCN network in the future.

[0043] Step S130: Input the target feature data into the transformer model, predict the node paths in the directed graph model through the transformer model, and determine the table connection order based on the node paths.

[0044] In an optional manner, step S130 further includes: extracting the context information of each node in the target feature data through the self-attention mechanism of the encoder of the transformer model, and sequentially inputting the context information of each node into the decoder of the transformer model; the decoder generates the node vector of the current node based on the context information of each node and the already generated node vector, and sequentially predicts the next node until the prediction ends when the predicted node is a preset end node; and connecting the sequentially predicted nodes to obtain the node path.

[0045] The transformer model has a good ability to escape local optima. Therefore, the task of predicting the database table join order is transformed into a seq2seq task by using the transformer model. This keeps the time complexity within the polynomial range, which is an order of magnitude improvement compared to NP-hard problems. Figure 4 This is a schematic diagram of the network structure in this embodiment, as shown below. Figure 4 As shown, in this step, the optimal node path selection problem is transformed into an encoder-decoder problem, and the optimal node path is determined through a machine translation-like approach. The structure of the transformer model includes an encoder and a decoder. The encoder receives the target feature data obtained in step S120, namely the node vector features of (N, 512). The encoder includes a feed-forward control unit and a self-attention unit. Self-attention is the core network unit. The encoder uses self-attention to summarize the semantic information of all nodes in the target feature data into the vector representation of each word, thereby fully extracting the context information of each node. The encoder output vector is defined as follows (1):

[0046] Z=Attention(Q,K,V);(1)

[0047] Equation (1) is the standard definition formula of the transformer model, which will not be described in detail in this embodiment. The detailed calculation process of equation (1) is as follows: Equation (2) and Equation (3). The final output vector dimension remains unchanged at (N, 512).

[0048]

[0049] FFN(Z)=max(0, ZW1+b1)W2+b2; (3)

[0050] In equation (2), the softmax function is the normalized exponential function; FFN(Z) is the formula for the feedforward network to process the parameters.

[0051] The context information of each node obtained from the encoder is sequentially input into the decoder of the transformer model. When generating each predicted node sequence, the decoder uses self-attention to focus on the elements previously generated by the encoder and incorporate their semantics into the subsequent predicted element vector (i.e., node vector). Then, self-attention is used to focus on the predicted output of the encoder and incorporate its information into the vector of the currently generated elements.

[0052] The decoder uses a fully connected layer plus a classification network (linear + softmax) to predict the next node, leveraging the representation features of all nodes and the already predicted node representation features. Figure 5a and Figure 5b This is a schematic diagram of the prediction process of the transformer model, as shown below. Figure 5a and Figure 5b As shown, the output vector is defined as N-dimensional, and a value of 1 indicates that a node can be output. For example, (0, 0, 1, 0, 0, 0, 0, 0, 0, 0) indicates that the third node is the prediction result. The prediction sequence always adds two nodes S and E; where S represents the start marker and E represents the end marker. The prediction starts from the current node S, and the prediction ends if the prediction node is E. Figure 5a This means predicting nodes C, G, and H sequentially starting from the current node S, and predicting the next node as A based on S, C, G, and H; Figure 5b The image shows the state at the end of the prediction process. When the prediction node is E, the entire process will end, and the final output node path will be S(C, G, H, A, J, B, D, E, F, I).

[0053] The method in this embodiment involves acquiring the data of the tables to be joined, constructing a directed graph model based on the data of the tables to be joined and the database cost model, determining the corresponding feature matrix and adjacency matrix based on the directed graph model, extracting features from the feature matrix and adjacency matrix through a graph convolutional network to obtain target feature data, inputting the target feature data into a transformer model, predicting the node paths in the directed graph model through the transformer model, and determining the table joining order based on the node paths. This method abstracts the database table join problem into a sequence prediction problem based on a directed graph model. Spatial features are extracted using a graph convolutional network, and selection decisions are made using a transformer model to predict node paths in the directed graph model, achieving optimal path selection. Deep learning is introduced into database table joins, fully utilizing the advantages of spatial features and node representation characteristics. The combination of graph convolutional networks and transformer models can complete node path prediction within polynomial time complexity, overcoming the shortcomings of existing genetic algorithms. Furthermore, the transformer model has a strong ability to escape local optima. Therefore, the database table join sequence task is transformed into a seq2seq task to complete the join sequence prediction using the transformer model, keeping the time complexity within the polynomial range, representing an order-of-magnitude improvement compared to NP-hard problems.

[0054] Figure 6 A schematic diagram of an embodiment of a database table join optimization device according to the present invention is shown. Figure 6 As shown, the device includes: a model building module 610, a feature extraction module 620, and a processing module 630.

[0055] The model building module 610 is used to obtain the data of the table to be joined and to build a directed graph model based on the data of the table to be joined and the database cost model.

[0056] In an alternative approach, the model building module 610 is further configured to: input the data of the tables to be joined into the database cost model, use the database cost model to obtain the cost information between the data of the tables to be joined; use the data of the tables to be joined as nodes, set the edges and directions between each node according to the cost information between the data of the tables to be joined, and construct a directed graph model.

[0057] The feature extraction module 620 is used to determine the corresponding feature matrix and adjacency matrix based on the directed graph model, and to extract the target feature data by using the feature matrix and adjacency matrix through a graph convolutional network.

[0058] In an optional manner, the feature extraction module 620 is further configured to: obtain table information of each node in the directed graph model, determine the node features of each node using the table information of each node, determine the feature matrix based on the node features, determine the graph structure features using the cost information between the data to be joined and the table sequence number of the data to be joined, and determine the adjacency matrix based on the graph structure features.

[0059] In one alternative approach, the table information includes one or more of the following: the table sequence number, number of rows, number of columns, and table size in bytes of the table data to be joined.

[0060] In an alternative approach, the feature extraction module 620 is further used to normalize the feature matrix and the adjacency matrix.

[0061] The processing module 630 is used to input the target feature data into the transformer model, predict the node paths in the directed graph model through the transformer model, and determine the table connection order based on the node paths.

[0062] In an optional manner, the processing module 630 is further configured to: extract the context information of each node in the target feature data through the self-attention mechanism of the encoder of the transformer model, and input the context information of each node into the decoder of the transformer model in sequence; the decoder generates the node vector of the current node based on the context information of each node and the already generated node vector, and predicts the next node in sequence until the prediction ends when the predicted node is a preset end node; and connects the nodes predicted in sequence to obtain the node path.

[0063] The apparatus of this embodiment acquires the data of the tables to be joined, constructs a directed graph model based on the data of the tables to be joined and the database cost model, determines the corresponding feature matrix and adjacency matrix based on the directed graph model, extracts features from the feature matrix and adjacency matrix through a graph convolutional network to obtain target feature data, inputs the target feature data into a transformer model, predicts the node paths in the directed graph model through the transformer model, and determines the table joining order based on the node paths. This apparatus abstracts the database table joining problem into a sequence prediction problem based on a directed graph model, extracts spatial features through a graph convolutional network, makes selection decisions through a transformer model, predicts the node paths in the directed graph model, and achieves optimal path selection. It introduces deep learning into database table joining, making full use of the advantages of spatial features and node representation characteristics. The combination of graph convolutional networks and transformer models can complete node path prediction in polynomial time complexity, making up for the shortcomings of genetic algorithms in the prior art.

[0064] This invention provides a non-volatile computer storage medium storing at least one executable instruction that can execute a database table join optimization method in any of the above method embodiments.

[0065] Executable instructions can specifically be used to cause the processor to perform the following operations:

[0066] Obtain the data from the tables to be joined, and construct a directed graph model based on the data from the tables to be joined and the database cost model;

[0067] Based on the directed graph model, the corresponding feature matrix and adjacency matrix are determined. The feature matrix and adjacency matrix are then used to extract features through a graph convolutional network to obtain the target feature data.

[0068] The target feature data is input into the transformer model, and the node paths in the directed graph model are predicted by the transformer model. The table connection order is determined based on the node paths.

[0069] Figure 7 The diagram shows a structural schematic of an embodiment of the computing device of the present invention. The specific embodiments of the present invention do not limit the specific implementation of the computing device.

[0070] like Figure 7 As shown, the computing device may include:

[0071] Processor, Communications Interface, Memory, and Communications Bus.

[0072] The processor, communication interface, and memory communicate with each other via a communication bus. The communication interface is used to communicate with other network elements, such as clients or other servers. The processor executes programs, specifically the steps described in this embodiment of the database table join optimization method.

[0073] Specifically, the program may include program code, which includes computer operation instructions.

[0074] The processor may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention. The server may include one or more processors of the same type, such as one or more CPUs; or it may include processors of different types, such as one or more CPUs and one or more ASICs.

[0075] Memory is used to store programs. Memory may include high-speed RAM, and may also include non-volatile memory, such as at least one disk drive.

[0076] Specifically, the program can be used to cause the processor to perform the following operations:

[0077] Obtain the data from the tables to be joined, and construct a directed graph model based on the data from the tables to be joined and the database cost model;

[0078] Based on the directed graph model, the corresponding feature matrix and adjacency matrix are determined. The feature matrix and adjacency matrix are then used to extract features through a graph convolutional network to obtain the target feature data.

[0079] The target feature data is input into the transformer model, and the node paths in the directed graph model are predicted by the transformer model. The table connection order is determined based on the node paths.

[0080] The algorithms or displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used in conjunction with the teachings herein. The required structure for constructing such systems is apparent from the above description. Furthermore, the embodiments of the present invention are not directed to any particular programming language. It should be understood that the content of the invention described herein can be implemented using various programming languages, and the above description of specific languages ​​is for the purpose of disclosing the best mode of implementation of the invention.

[0081] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.

[0082] Similarly, it should be understood that, in order to simplify the invention and aid in understanding one or more of the various inventive aspects, features of the embodiments of the invention are sometimes grouped together in a single embodiment, figure, or description thereof in the above description of exemplary embodiments of the invention. However, this disclosure should not be construed as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Rather, as reflected in the following claims, inventive aspects lie in fewer than all features of a single foregoing disclosed embodiment. Therefore, the claims following the detailed description are hereby expressly incorporated into this detailed description, wherein each claim itself is a separate embodiment of the invention.

[0083] Those skilled in the art will understand that modules in the device of the embodiments can be adaptively changed and placed in one or more devices different from that embodiment. Modules, units, or components in the embodiments can be combined into a single module, unit, or component, and further, they can be divided into multiple sub-modules, sub-units, or sub-components. Except where at least some of such features and / or processes or units are mutually exclusive, any combination can be used to combine all features disclosed in this specification (including the accompanying claims, abstract, and drawings) and all processes or units of any method or device so disclosed. Unless expressly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstract, and drawings) may be replaced by an alternative feature that serves the same, equivalent, or similar purpose.

[0084] Furthermore, those skilled in the art will understand that although some embodiments herein include certain features included in other embodiments but not others, combinations of features from different embodiments are intended to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments can be used in any combination.

[0085] The various component embodiments of the present invention can be implemented in hardware, or as software modules running on one or more processors, or a combination thereof. Those skilled in the art will understand that microprocessors or digital signal processors (DSPs) can be used in practice to implement some or all of the functions of some or all of the components according to the embodiments of the present invention. The present invention can also be implemented as a device or apparatus program (e.g., a computer program and computer program product) for performing part or all of the methods described herein. Such programs implementing the present invention can be stored on a computer-readable medium, or can be in the form of one or more signals. Such signals can be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.

[0086] It should be noted that the above embodiments are illustrative of the invention and not restrictive, and that those skilled in the art can devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names. The steps in the above embodiments, unless otherwise specified, should not be construed as limiting the order of execution.

Claims

1. A database table join optimization method, characterized in that, include: Obtain the data of the table to be joined, and construct a directed graph model based on the data of the table to be joined and the database cost model; wherein, the nodes in the directed graph model are the data of the table to be joined, and the edges between each node and the direction of the edges are set according to the cost information between the data of the table to be joined. Based on the directed graph model, the corresponding feature matrix and adjacency matrix are determined. The feature matrix and adjacency matrix are then used to extract features through a graph convolutional network to obtain target feature data. The target feature data is used to reflect Euclidean space information, node relationships, and node features. The target feature data is input into the transformer model, and the node paths in the directed graph model are predicted by the transformer model. The table join order is determined based on the node paths. The step of determining the corresponding feature matrix and adjacency matrix based on the directed graph model further includes: Obtain the table information of each node in the directed graph model, use the table information of each node to determine the node characteristics of each node, and determine the feature matrix based on the node characteristics. The graph structure features are determined by using the cost information between the data in the tables to be joined and the table sequence number of the data in the tables to be joined, and the adjacency matrix is ​​determined based on the graph structure features.

2. The method according to claim 1, characterized in that, The construction of the directed graph model based on the data of the tables to be joined and the database cost model further includes: The data of the tables to be joined is input into the database cost model, and the cost information between the data of the tables to be joined is obtained using the database cost model.

3. The method according to claim 1, characterized in that, The table information includes one or more of the following: the table sequence number, number of rows, number of columns, and table size in bytes of the table data to be joined.

4. The method according to claim 1, characterized in that, After determining the corresponding feature matrix and adjacency matrix based on the directed graph model, the method further includes: The feature matrix and the adjacency matrix are normalized.

5. The method according to any one of claims 1-4, characterized in that, The step of predicting node paths in a directed graph model using a transformer model further includes: The context information of each node in the target feature data is extracted through the self-attention mechanism of the encoder of the transformer model, and the context information of each node is sequentially input into the decoder of the transformer model. The decoder generates the node vector of the current node based on the context information of each node and the already generated node vectors, and predicts the next node in sequence until the prediction ends when the predicted node is a preset end node. The node paths are obtained by connecting the predicted nodes in sequence.

6. A database table join optimization device, characterized in that, include: The model building module is used to obtain the data of the table to be joined and to build a directed graph model based on the data of the table to be joined and the database cost model; wherein, the nodes in the directed graph model are the data of the table to be joined, and the edges between each node and the direction of the edges are set according to the cost information between the data of the table to be joined. The feature extraction module is used to determine the corresponding feature matrix and adjacency matrix based on the directed graph model, and to extract the features from the feature matrix and adjacency matrix through a graph convolutional network to obtain target feature data; the target feature data is used to reflect Euclidean space information, node relationships, and node features; The processing module is used to input the target feature data into the transformer model, predict the node paths in the directed graph model through the transformer model, and determine the table join order based on the node paths. The feature extraction module is further configured to: obtain table information of each node in the directed graph model; determine the node features of each node using the table information of each node; determine the feature matrix based on the node features; determine the graph structure features using the cost information between the data to be joined and the table sequence number of the data to be joined; and determine the adjacency matrix based on the graph structure features.

7. The apparatus according to claim 6, characterized in that, The model building module is further used for: The data of the tables to be joined is input into the database cost model, and the cost information between the data of the tables to be joined is obtained using the database cost model.

8. A computing device, characterized in that, include: The processor, memory, communication interface, and communication bus are provided, wherein the processor, memory, and communication interface communicate with each other via the communication bus. The memory is used to store at least one executable instruction, which causes the processor to perform an operation corresponding to the database table join optimization method as described in any one of claims 1-5.

9. A computer storage medium, characterized in that, The storage medium stores at least one executable instruction, which causes the processor to perform the operation corresponding to the database table join optimization method as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Program understanding method and system based on abstract syntax tree

    CN112835585A

  • Database processing method and device

    CN113111058A