Database connection order adjustment method based on encoder-decoder architecture

By using an encoder-decoder architecture and a transformer model for training, the true cardinality of predicates for table sequences and column sets is obtained, solving the problems of time-consuming, labor-intensive, and suboptimal planning in traditional methods, and achieving efficient and accurate database connection order adjustment.

CN119691042BActive Publication Date: 2025-10-31NINGXIA UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411778125.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-05
Publication Date
2025-10-31
Estimated Expiration
2044-12-05

AI Technical Summary

Technical Problem

In database query optimization, traditional join order adjustment methods are time-consuming and labor-intensive, and heuristic algorithms and pure decoder-BERT methods cannot accurately integrate the mapping between SQL execution plan information and the optimal execution plan, resulting in suboptimal plans.

Method used

Employing an encoder-decoder architecture, the system constructs a predicate set by acquiring table sequences and column sets, obtains the true cardinality of the predicates, and injects them into the syntax tree of the SQL statement. Combined with transformer model training, it ultimately generates optimal join order data, reflecting the mapping relationship between the database execution plan and the optimal execution plan.

Benefits of technology

It achieves efficient and accurate database connection order adjustment, avoids the generation of suboptimal plans, enhances the generalization ability of the model, and improves the efficiency of query optimization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119691042B_ABST
    Figure CN119691042B_ABST
Patent Text Reader

Abstract

This invention discloses a database join order adjustment method based on an encoder-decoder architecture, relating to the technical field. The method includes: extracting table sequences of different lengths and their column sets from a database, constructing a predicate set for each column, and integrating the information to obtain original join order data; constructing corresponding SQL statements for each table sequence based on the original join order data, executing the SQL statements through a database management system to obtain the true cardinality of the predicates, and updating the original join order data; injecting the true cardinality of the predicates into the syntax tree of the SQL statement, optimizing the query, and extracting table data information from its physical operator tree to obtain optimal join order data; training a transformer model using the original and optimal join order data; and inputting a preprocessed SQL statement from a new query into the model to obtain accurate join order adjustment results.
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 in particular to a method for adjusting the database connection order based on an encoder-decoder architecture. Background Technology

[0002] Currently, join order selection is a critical issue in database query optimization, directly impacting query execution efficiency. In practical applications, query optimizers face complex query spaces and massive data volumes, making the efficient selection of the optimal join order a persistent challenge. Traditional static join order enumeration algorithms search for the optimal solution by thoroughly traversing the query space, but this approach is often time-consuming, resource-intensive, and even infeasible when dealing with large datasets and complex queries. To address this issue, modern query optimizers typically employ a combination of heuristic algorithms and static methods. Therefore, join order selection is a crucial problem in database query optimization, directly affecting query performance and efficiency, and optimizers are continuously adopting new algorithms and methods to solve this challenge and provide faster data processing capabilities.

[0003] In existing technologies, with the development of technology, modern database systems have adopted more advanced optimization techniques, such as machine learning, to predict the optimal join order. These techniques can adapt to different query patterns and data distributions, providing more dynamic and accurate optimization decisions. Heuristic algorithms can find a near-optimal solution in a shorter time. Recent research uses a pure decoder—BERT—for join order adjustment, setting the join order as a downstream task of BERT, thus optimizing the join order adjustment.

[0004] However, traditional database query join order adjustment mainly relies on heuristic rules, which suffers from severe performance degradation in complex query environments. To address this issue, reinforcement learning-based join order adjustment has been proposed, but it consumes excessive resources and heavily relies on reward functions. Recent research uses a pure decoder—BERT—for join order adjustment, making join order a downstream task of BERT. However, it lacks a mapping between SQL execution plan information and the optimal execution plan in its dataset, leading to suboptimal plans and thus failing to provide accurate join order adjustment results.

[0005] Therefore, how to integrate the mapping between SQL execution plan information and the optimal execution plan, avoid the generation of suboptimal plans, and thus efficiently provide accurate join order adjustment results is a problem that needs to be solved. Summary of the Invention

[0006] Therefore, it is necessary to provide a database connection order adjustment method based on an encoder-decoder architecture to address the aforementioned technical problems.

[0007] The present invention adopts the following technical solution:

[0008] This invention provides a method for adjusting the database connection order based on an encoder-decoder architecture, including:

[0009] Obtain table sequences of different lengths from the database, and obtain the column set of each table in each table sequence; construct the predicate set corresponding to each column in the column set; fill the table sequence with data including the table, each column of the table, and the predicate set corresponding to each column to obtain the original join order data;

[0010] For each table sequence in the original join data, construct the corresponding SQL statement for each table sequence; through the database management system, execute the SQL statement corresponding to each table sequence to obtain the true cardinality of the predicates in each table sequence, and add the true cardinality of the predicates to the original join order data during the execution of the SQL statement; inject the true cardinality of the predicates in the original join order data into the syntax tree corresponding to the SQL statement to obtain the physical operator tree of the query optimization result, and extract the table data information of each leaf node of the physical operator tree to obtain the optimal join order data;

[0011] The original join order data and the optimal join order data of the table are used as training sets to train the transformer model and obtain the final transformer model.

[0012] The data retrieved by the newly entered SQL statement is adjusted through simple data processing to conform to the original join order data format and then input into the final transformer model to obtain the join order adjustment result of the tables.

[0013] Preferably, obtaining the original connection sequence data includes the following steps:

[0014] The database is constructed with a table sequence T = {t}, and the column set of each table is constructed as t = {c}; where i, j = 1, 2, 3, ..., {t} represents the table sequence, t is a table in the table sequence, {c} is the column set of a table, and c represents a column in the column set; furthermore, the range of values ​​for each column c is... This represents the minimum value of column c in table t. This represents the maximum value of column c in table t;

[0015] For a list sequence {t}, construct all permutations of lists from 1 to |{t}|, where each permutation corresponds to a join order of the lists, for a total of k join orders; where k = 1 + 2! + ... + |{t}|! ;

[0016] For each table with a join order, obtain its corresponding column set {c}, and for each column, construct its corresponding predicate set P;

[0017] Construct a set of tables by using each table t, each column c corresponding to table t, and the predicate set P corresponding to each column in each join order. Among them, symbols Represents the Cartesian product;

[0018] Select tables from 1 to k in sequence according to the join order. For table i, a total of For each possible permutation, table t will be used. x Change to in, Indicates all permutations. Indicates attachment to table t x The list, Indicates dependence on the list The predicate;

[0019] The set formed by the arrangement of all the modified tables is used as the original join order data.

[0020] Preferably, constructing the predicate set P corresponding to each column includes the following steps:

[0021] Sort the values ​​in the column in ascending order to get sequence A;

[0022] K values ​​are randomly selected from sequence A as the centers of the data clusters; the choice of K is determined by the amount of data in sequence A, and the larger the amount of data in sequence A, the larger the value of K.

[0023] Subtract K values ​​from sequence A, calculate the distance of the remaining values ​​from the cluster center, and assign the data points to the cluster corresponding to the nearest cluster center;

[0024] Calculate the mean of all member data points in the cluster and update the position of the cluster center;

[0025] Repeat the above steps until the position of the cluster center no longer changes, obtain all clusters for each column, and form a predicate p; where each cluster corresponds to an interval, each interval is [rl,ru], rl and ru represent the minimum and maximum values ​​corresponding to the interval respectively, and rl≤p≤ru, p∈P, where P is the set of predicates corresponding to each column.

[0026] Preferably, obtaining the optimal connection order data includes the following steps:

[0027] For each table sequence in the original join sequence data, construct the corresponding SQL statement and save the constructed SQL statement in a separate file to obtain the original SQL file;

[0028] The database management system is used to execute the above SQL statement to obtain the true cardinality of the columns in the table sequence under the predicate;

[0029] When the database management system reaches the syntax tree generation stage, it changes the pre-saved data information table-column-predicate (tcp) of each leaf node of the syntax tree to table-column-predicate-true cardinality (tcpe);

[0030] When the database management system reaches the query optimization stage, the input parameters of the cost model within the database management system are changed from the preset cardinality to the actual cardinality.

[0031] Once the database management system has finished executing, it obtains the query optimization results of the SQL statement, i.e., the number of physical operators;

[0032] Extract the data information of the leaf nodes of the physical operator tree in a left-to-right, top-to-bottom order to obtain an optimal table sequence;

[0033] By performing the above steps on all table sequences in the original join order data, we obtain all optimal table sequences. The set of all optimal table sequences is the optimal continuous order data.

[0034] The original sequential data in the database is replaced with the optimal sequential data, and then saved in another separate file to obtain the optimal SQL file.

[0035] Preferably, obtaining the final transformer model includes the following steps:

[0036] Obtain the dataset for the transformer model;

[0037] Divide the dataset into a training set and a validation set according to a specified ratio;

[0038] The training set is input into an existing transformer model for training; wherein the parameters of the transformer model are either default parameters or adjusted as needed;

[0039] The trained transformer model was validated and optimized using a validation set.

[0040] Preferably, obtaining the dataset for the transformer model includes:

[0041] Save the original sequential data and the optimal sequential data to a text file;

[0042] Let the original sequential data be JS = {js}, and the optimal sequential data be OJS = {ojs}; where js} represents the set of data elements in the original sequential data, and js is one of the elements; and {ojs} represents the set of data elements in the original sequential data, and ojs is one of the elements.

[0043] Using data elements from the original continuous sequential data and the optimal continuous sequential data, the data format of each line in the text file is constructed as: "JS":"js","OJS":"ojs". The data in this text file is the dataset of the transformer model.

[0044] Preferably, the step of validating and optimizing the trained transformer model using a validation set includes:

[0045] Input the validation set into the trained transformer model, output the model's validation results, judge the model's performance based on the validation results and optimize it, and save the SQL statements corresponding to the poor validation results to a separate file, which is the optimization SQL file.

[0046] The step of judging and optimizing the model based on the verification results includes:

[0047] If the output results are inconsistent with the number of tables or the contents of the tables, it indicates that the model has a serious generalization problem. The tuning SQL file needs to be merged with the original SQL file, and the model needs to be retrained for tuning.

[0048] If the model output is in the correct format, but the execution effect of the SQL statement corresponding to the validation set data is not as good as the execution effect of the optimal SQL corresponding to the original SQL statement, it is necessary to further add a high-quality dataset to optimize the model.

[0049] The above-mentioned at least one technical solution adopted in this invention can achieve the following beneficial effects:

[0050] The database connection order adjustment method based on encoder-decoder architecture provided by this invention obtains table sequences of different lengths and their column sets, constructs a predicate set for each column, and fills the table sequence with data including the table, each column corresponding to the table, and the predicate set corresponding to each column to obtain the original connection order data. Based on each table sequence of the original connection order data, a corresponding SQL statement is constructed, the SQL statement is executed to obtain the true cardinality of the predicates, and the original connection order data is updated. The true cardinality of the predicates is injected into the syntax tree of the SQL statement for query optimization, and data is extracted from the nodes of the optimized physical operator tree to obtain the optimal connection order data, thereby reflecting the mapping relationship between the SQL execution plan level and the optimal execution plan.

[0051] In summary, this invention constructs original join order data and obtains optimal join order data based on it, thereby reflecting the mapping relationship between the database execution plan level and the optimal execution plan, thus avoiding the generation of suboptimal plans. Attached Figure Description

[0052] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this invention, illustrate exemplary embodiments of the invention and are used to explain the invention, but do not constitute an undue limitation of the invention. In the drawings:

[0053] Figure 1 This is a flowchart illustrating the database connection order adjustment method based on an encoder-decoder architecture provided by the present invention. Detailed Implementation

[0054] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0055] The technical solutions provided by the various embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0056] This embodiment provides a method for adjusting the database connection order based on an encoder-decoder architecture, and its flowchart is shown below. Figure 1 As shown, it includes the following steps:

[0057] S101: Obtain a large number of table sequences of varying lengths from the corresponding tables in the database; construct the column set for each table in each table sequence, and construct the predicate set corresponding to each column in the column set to obtain the predicate set for all columns; fill the table sequence with data including the tables, the columns corresponding to the tables, and the predicate set corresponding to each column to obtain the original join order data, specifically including:

[0058] Based on the database, its table sequence is constructed as T = {t} i}, the column set of each table constructed by the merged table sequence is t = {a j}; where i,j = 1, 2, 3, ...; each column c j The range of values ​​is Represents table t i One column c j The minimum value, Represents table t i One column c j The maximum value;

[0059] For the table sequence {t i}, construct numbers from 1 to |{t} respectively. i The table}| is a set of permutations, each permutation corresponding to a unique join order. A total of k join orders are constructed, where k = 1 + 2! + ... + |{t}. i}|! ;

[0060] For each join order of the table, obtain its corresponding column set {c j}, and for each column, construct a predicate set P corresponding to it, including:

[0061] Sort the values ​​in the column in ascending order to get sequence A;

[0062] K values ​​are randomly selected from sequence A as the centers of the data clusters; the choice of K is determined by the amount of data in sequence A, and the larger the amount of data in sequence A, the larger the value of K.

[0063] Subtract K values ​​from sequence A, calculate the distance of the remaining values ​​from the cluster center, and assign the data points to the cluster corresponding to the nearest cluster center;

[0064] Calculate the mean of all member data points in the cluster and update the position of the cluster center;

[0065] Repeat the above steps until the position of the cluster center no longer changes, obtain all clusters of the column, and form the predicate p; where each cluster corresponds to an interval, each interval is [rl,ru], rl and ru represent the minimum and maximum values ​​of the interval respectively, and rl≤p≤ru, p∈P;

[0066] Through each table t in each join orderi Table t i Each corresponding column a t And the predicate set P corresponding to each column, constructing the table set. Among them, symbols Represents the Cartesian product;

[0067] Select tables from 1 to k in sequence according to the join order. For table i, a total of For each possible permutation, table t will be used. x Change to in, Indicates all permutations. Indicates attachment to table t x The list, Indicates dependence on the list The predicate;

[0068] The set formed by the arrangement of all the changed tables is the original join order data.

[0069] S102: Construct the SQL statement corresponding to each table sequence in the original join data; execute the SQL statement corresponding to the table sequence through the database management system to obtain the true cardinality of the predicates in the table sequence, and add the true cardinality of the predicates to the original join order data during the execution of the SQL statement; inject the true cardinality of the predicates in the original join order data into the syntax tree corresponding to the constructed SQL statement, extract the table data information of each leaf node of the syntax tree, and obtain the optimal join order data, specifically including:

[0070] For each table sequence in the original join sequence data, construct the corresponding SQL statement and save the constructed SQL statement in a separate file to obtain the original database file;

[0071] The database management system is used to execute the above SQL statement to obtain the true cardinality of the columns in the table sequence under the predicate;

[0072] When the database management system reaches the syntax tree generation stage, it changes the pre-saved data information table-column-predicate (tcp) of each leaf node of the syntax tree to table-column-predicate-true cardinality (tcpe);

[0073] When the database management system reaches the query optimization stage, the input parameters of the cost model within the database management system are changed from the preset cardinality to the actual cardinality.

[0074] Once the database management system has finished executing, it obtains the query optimization results of the SQL statement, i.e., the number of physical operators;

[0075] Extract the data information of the leaf nodes of the physical operator tree in a left-to-right, top-to-bottom order to obtain an optimal table sequence;

[0076] By performing the above steps on all table sequences in the original join order data, we obtain all optimal table sequences. The set of all optimal table sequences is the optimal continuous order data.

[0077] The original sequential data in the database is replaced with the optimal sequential data, and then saved in another independent file to obtain the optimal database file.

[0078] S103: Train the transformer model using the original join order data and the optimal join order data of the table as the training set, and fine-tune the model based on the training results to obtain the final transformer model, specifically including:

[0079] Obtain the dataset for the transformer model;

[0080] The dataset is divided into training and validation sets according to a specified ratio, including:

[0081] Save the original sequential data and the optimal sequential data to a text file;

[0082] Let the original sequential data be JS = {js}, and the optimal sequential data be OJS = {ojs}; where {js} represents the set of data elements in the original sequential data, and js is one of the elements; and {ojs} represents the set of data elements in the original sequential data, and ojs is one of the elements.

[0083] Using the data elements from the original continuous sequential data and the optimal continuous sequential data, the data format of each line in the text file is constructed as: "JS":"js","OJS":"ojs". The data in this text file is the dataset of the transformer model.

[0084] The training set is input into an existing transformer model for training; wherein the parameters of the transformer model are either default parameters or adjusted as needed;

[0085] The trained transformer model is validated and tuned using a validation set, including:

[0086] Input the validation set into the trained transformer model, output the model's validation results, judge the model's performance based on the validation results and optimize it, and save the SQL statements corresponding to the poor validation results to a separate file, which is the optimization SQL file.

[0087] The step of judging and optimizing the model based on the verification results includes:

[0088] If the output results show inconsistencies in the number of tables or the content of the tables, it indicates that the model has a serious generalization problem. The tuning SQL file needs to be merged with the original SQL file, and the model needs to be retrained for tuning.

[0089] If the model output is in the correct format, but the execution effect of the SQL statement corresponding to the validation set data is not as good as the execution effect of the optimal SQL corresponding to the original SQL statement, it is necessary to further add a high-quality dataset to optimize the model.

[0090] S104: The data retrieved by the newly entered SQL statement is adjusted to conform to the original join order data format through simple data processing, and then input into the final transformer model to obtain the join order adjustment result of the table.

[0091] This embodiment uses a database provided by a publicly available benchmark. Through the above steps, accurate database connection order adjustment results are achieved, including:

[0092] According to the method in step S101, the table sequence D = {t1, t2, t3} is obtained by publicly accessing the Benchmark database;

[0093] The data pattern for each table is as follows: t1:{c1int}; t2:{c1int}; t3:{c1int}, where c1 represents a column of table t1, t2, and t3 respectively, and int represents an integer.

[0094] The column data for each table is as follows:

[0095] t1.c1:{1,3,4,7,2,10,8,9,11,13,15}

[0096] t2.c1:{11,13,15,20,25,31,22,27,40};

[0097] t3.c1:{35,37,30,31,24,44,43}

[0098] For the aforementioned database, the method for solving the predicate set corresponding to each table according to step S101 is as follows: as well as

[0099] To construct the original sequential join data, taking one of the join sequential data as an example, the specific steps are as follows:

[0100] Based on the method in step S102, construct the SQL statement for joining the ordered data, and calculate the true cardinality of the predicates in each column of each table:

[0101]

[0102] in, as well as This represents the true cardinality of the predicate in column c1 of tables t1, t3, and t2. This represents the first predicate element in the predicate set of table t1. This represents the 0th predicate element in the predicate set of table t3. This represents the first predicate element in the predicate set of table t2;

[0103] Replace the original join order data with the true cardinality of the predicates corresponding to each of the above tables.

[0104] For the replaced original join order data, construct the following SQL statement:

[0105] select 1from t1,t3,t2 where t1.c1=t3.c1 and t3.c1=t2.c1 and

[0106] Execute the above statements, and during the execution process, calculate the true cardinality of the predicate corresponding to each table. as well as Injected into the corresponding syntax tree node, the query optimization result, i.e., the physical operator tree, is captured. The data information of each node in the physical operator tree is extracted to obtain the optimal join order data:

[0107] Based on the method in step S103, construct the dataset for the transformer model:

[0108] "JS": “OJS”:

[0109] Based on the above data, the transformer model was trained and optimized to obtain the final transformer model.

[0110] According to the method in step S104, for the newly input SQL query statement, the data queried is converted into a dataset in the format of "JS":"js","OJS":"ojs" and input into the final transformer model to obtain the connection order adjustment result.

[0111] In summary, the verification through this embodiment demonstrates that the present invention, by constructing original join order data and obtaining optimal join order data based on it, reflects the mapping relationship between the database execution plan level and the optimal execution plan, thus avoiding the generation of suboptimal plans. Simultaneously, by replacing the original database join order adjustment process online, and through offline training and continuous tuning of the transformer model, the generalization ability of the model is enhanced, thereby obtaining the join order adjustment results efficiently and accurately.

[0112] The technical solutions of the present invention are not limited to the specific embodiments described above. Any technical modifications made in accordance with the technical solutions of the present invention fall within the protection scope of the present invention.

Claims

1. A database connection order adjustment method based on an encoder-decoder architecture, characterized in that, The method includes the following steps: Obtain table sequences of different lengths from the database, and obtain the column set of each table in each table sequence; construct the predicate set corresponding to each column in the column set; fill the table sequence with data including the table, each column of the table, and the predicate set corresponding to each column to obtain the original join order data; For each table sequence in the original join data, construct the corresponding SQL statement for each table sequence; execute the SQL statement for each table sequence using the database management system to obtain the true cardinality of the predicates in each table sequence, and add the true cardinality of the predicates to the original join order data during the execution of the SQL statement; inject the true cardinality of the predicates in the original join order data into the syntax tree corresponding to the SQL statement to obtain the physical operator tree of the query optimization result, and extract the table data information of each leaf node of the physical operator tree to obtain the optimal join order data; wherein, obtaining the optimal join order data specifically includes: for each table sequence in the original join order data, construct the corresponding SQL statement, and save the constructed SQL statement in a separate file to obtain the original SQL file; execute the above SQL statement using the database management system to obtain the true cardinality of the columns in the table sequence under the predicates; when the database management system reaches the syntax tree generation stage, the data information table-column-predicate (preserved in advance) of each leaf node of the syntax tree is used to obtain the true cardinality of the columns in the table sequence under the predicates; when the database management system reaches the syntax tree generation stage, the data information table-column-predicate (preserved in advance) of each leaf node of the syntax tree is used to obtain the true cardinality of the columns in the table sequence under the predicates; tc- p Change to Table-Column-Predicate-True Cardinality tcpe When the database management system reaches the query optimization stage, the input parameters of the cost model within the database management system are changed from the preset cardinality to the actual cardinality. When the database management system finishes execution, the query optimization result of the SQL statement is obtained, i.e., the number of physical operators. The data information of the leaf nodes of the physical operator tree is extracted in the order from left to right and from top to bottom to obtain an optimal table sequence. All table sequences in the original join order data are processed through the above steps to obtain all optimal table sequences. The set of all optimal table sequences is the optimal continuous order data. The original sequential data in the database is replaced with the optimal sequential data, and then saved in another separate file to obtain the optimal SQL file; The original join order data and the optimal join order data of the table are used as training sets to train the transformer model and obtain the final transformer model. The new query SQL statement is preprocessed to obtain data in a format that conforms to the original join order, and then input into the final transformer model to obtain the join order adjustment result of the tables.

2. The database connection order adjustment method based on encoder-decoder architecture as described in claim 1, characterized in that, Obtaining the original connection order data includes the following steps: The table sequence is constructed based on the database. The merged table sequence constructs the column set of each table as follows: ;in, , Represents a table sequence. It is a table in a table sequence. A collection of columns from a table. This represents one column in the column set; the others, each column... The range of values ​​is , Representation Table One of the columns The minimum value, Representation Table One of the columns The maximum value; For table sequences Construct one to two numbers respectively. All permutations of the table, each permutation corresponding to a table join order, are constructed in total. Such connection order; among which, ; For each join order of the table, obtain its corresponding column set. And for each column, construct the corresponding set of predicates. P ; Through each table in each join order ,surface Each corresponding column and the predicate set corresponding to each column. P Construct a set of tables Among them, symbols Represents the Cartesian product; Select the number from 1 to 1 in sequence from the connection order. k The number of tables, referring to the number of tables i , contains For each possible permutation, the table will be... Change to table ;in, Indicates all permutations. Indicates attachment to the table The list, Indicates dependence on the list The predicate; The set formed by the arrangement of all the modified tables is used as the original join order data.

3. The database connection order adjustment method based on encoder-decoder architecture as described in claim 2, characterized in that, For each column, a predicate set corresponding to it is constructed using the K-means clustering algorithm. P This includes the following steps: Sort the values ​​in the column in ascending order to get sequence A; K values ​​are randomly selected from sequence A as the centers of the data clusters; the choice of K is determined by the amount of data in sequence A, and the larger the amount of data in sequence A, the larger the value of K. Subtract K values ​​from sequence A, calculate the distance of the remaining values ​​from the cluster center, and assign the data points to the cluster corresponding to the nearest cluster center; Calculate the mean of all member data points in the cluster and update the position of the cluster center; Repeat the above steps until the position of the cluster center no longer changes, obtain all clusters for each column, and form a predicate. Each cluster corresponds to an interval, and each interval is... , rl and ru Let represent the minimum and maximum values ​​corresponding to the intervals, respectively. .

4. The database connection order adjustment method based on encoder-decoder architecture as described in claim 1, characterized in that, The final transformer model is obtained by the following steps: Obtain the dataset for the transformer model; Divide the dataset into a training set and a validation set according to a specified ratio; The training set is input into an existing transformer model for training; wherein the parameters of the transformer model are either default parameters or adjusted as needed; The trained transformer model was validated and optimized using a validation set.

5. The database connection order adjustment method based on encoder-decoder architecture as described in claim 4, characterized in that, The acquisition of the dataset for the transformer model includes: Save the original sequential data and the optimal sequential data to a text file; Let the original sequential data be... The optimal continuous order data is ;in, This represents the set of data elements in the original sequential data. One of the elements; This represents the set of data elements in the original sequential data. One of the elements; Using data elements from the original sequential data and the optimal sequential data, the data format for each line in the text file is constructed as follows: The data in this text file is the dataset for the transformer model.

6. The database connection order adjustment method based on encoder-decoder architecture as described in claim 4, characterized in that, The step of validating and optimizing the trained transformer model using a validation set includes: Input the validation set into the trained transformer model, output the model's validation results, judge the model's performance based on the validation results and optimize it, and save the SQL statements corresponding to the poor validation results to a separate file, which is the optimization SQL file. The step of judging and optimizing the model based on the verification results includes: If the output results are inconsistent with the number of tables or the contents of the tables, it indicates that the model has a serious generalization problem. The tuning SQL file needs to be merged with the original SQL file, and the model needs to be retrained for tuning. If the model output is in the correct format, but the execution effect of the SQL statement corresponding to the validation set data is not as good as the execution effect of the optimal SQL corresponding to the original SQL statement, it is necessary to further add a high-quality dataset to optimize the model.

Citation Information

Patent Citations

  • Database query optimization method and system based on graph neural network

    CN113010547A

  • Cardinality estimation method based on attention mechanism

    CN118377781A