Multi-table connection processing method, device, equipment and machine-readable storage medium
Through the deep reinforcement learning model, the execution plan connection sequence of multi-table join query is solved, and the problem of difficulty in selecting the optimal execution plan in the existing technology is improved, and query efficiency and performance are improved.
Patent Information
- Application Number
- CN202010762744.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-31
- Publication Date
- 2025-02-21
- Estimated Expiration
- 2040-07-31
AI Technical Summary
The prior art is difficult to effectively select the optimal execution plan in multi-table join query, resulting in inefficient query.
By generating the initial execution plan and its characteristics, the connection order of execution plan is optimized using deep reinforcement learning models (such as Tree-LSTM networks) to train the target network model to improve query efficiency.
It realizes the execution plan with better performance in a short time, and improves the efficiency and performance of multi-table join query.
Smart Images

Figure CN113297206B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, and in particular to a method, device, equipment and machine-readable storage medium for processing multi-table connections. Background Art
[0002] With the emergence of large-scale databases and data warehouses, the size of databases is increasing day by day. How to find an execution plan that meets user query requirements and improve database query efficiency has become a hot topic in current research. For example, in the application scenario of a database, a query optimizer can be deployed, which can receive SQL (Structured Query Language) query requests and automatically generate an efficient execution plan corresponding to the SQL query request, thereby improving database query efficiency.
[0003] Multi-table join query is a typical application of SQL and is frequently used in databases. Multi-table join query involves multiple data tables. Different join orders of multiple data tables correspond to different execution plans, and the performance of these execution plans varies greatly. Therefore, it is necessary to select the optimal execution plan from these execution plans.
[0004] In order to select the best execution plan from these execution plans, the performance of each execution plan can be estimated, and the execution plan with the best performance can be used as the best execution plan. However, it takes a long time to estimate the performance of each execution plan, and the estimation result may be inaccurate, resulting in the inability to select the execution plan with the best performance. Summary of the invention
[0005] The present application provides a method for processing multi-table connections, the method comprising:
[0006] Generate a first sample execution plan according to a sample multi-table join query request;
[0007] Inputting a first sample feature corresponding to the first sample execution plan into an initial network model, and obtaining a second sample feature by the initial network model according to the first sample feature;
[0008] generating a second sample execution plan based on the second sample feature; wherein a connection order in the second sample execution plan is different from a connection order in the first sample execution plan;
[0009] The initial network model is trained based on the performance of the first sample execution plan and the performance of the second sample execution plan to obtain a trained target network model.
[0010] The present application provides a method for processing multi-table connections, the method comprising:
[0011] Generate a first detection execution plan according to a detection multi-table connection query request;
[0012] Inputting a first detection feature corresponding to the first detection execution plan into a trained target network model, and obtaining a second detection feature by the target network model according to the first detection feature;
[0013] Generate a second detection execution plan based on the second detection feature; wherein the connection order in the second detection execution plan is different from or the same as the connection order in the first detection execution plan;
[0014] Multi-table join query processing is performed based on the second detection execution plan.
[0015] The present application provides a multi-meter connection processing device, the device comprising:
[0016] A generation module, used to generate a first sample execution plan according to a sample multi-table connection query request;
[0017] An input module, used for inputting a first sample feature corresponding to the first sample execution plan into an initial network model, so that the initial network model obtains a second sample feature according to the first sample feature;
[0018] The generating module is further used to generate a second sample execution plan based on the second sample feature; the connection order in the second sample execution plan is different from the connection order in the first sample execution plan;
[0019] A training module is used to train the initial network model based on the performance of the first sample execution plan and the performance of the second sample execution plan to obtain a trained target network model.
[0020] The present application provides a multi-meter connection processing device, the device comprising:
[0021] A generation module is used to generate a first detection execution plan according to a multi-table connection query request; an input module is used to input a first detection feature corresponding to the first detection execution plan into a trained target network model, and the target network model obtains a second detection feature according to the first detection feature; the generation module is also used to generate a second detection execution plan based on the second detection feature; wherein the connection order in the second detection execution plan is different from or the same as the connection order in the first detection execution plan; a processing module is used to perform multi-table connection query processing based on the second detection execution plan.
[0022] The present application provides a multi-meter connection processing device, including:
[0023] A processor and a machine-readable storage medium, wherein the machine-readable storage medium stores a plurality of computer instructions, and when the processor executes the computer instructions, the processor performs the following processing:
[0024] Generate a first sample execution plan according to a sample multi-table join query request;
[0025] Inputting a first sample feature corresponding to the first sample execution plan into an initial network model, and obtaining a second sample feature by the initial network model according to the first sample feature;
[0026] generating a second sample execution plan based on the second sample feature; wherein a connection order in the second sample execution plan is different from a connection order in the first sample execution plan;
[0027] The initial network model is trained based on the performance of the first sample execution plan and the performance of the second sample execution plan to obtain a trained target network model.
[0028] The present application provides a multi-meter connection processing device, including:
[0029] A processor and a machine-readable storage medium, wherein the machine-readable storage medium stores a plurality of computer instructions, and when the processor executes the computer instructions, the processor performs the following processing:
[0030] Generate a first detection execution plan according to a detection multi-table connection query request;
[0031] Inputting a first detection feature corresponding to the first detection execution plan into a trained target network model, and obtaining a second detection feature by the target network model according to the first detection feature;
[0032] Generate a second detection execution plan based on the second detection feature; wherein the connection order in the second detection execution plan is different from or the same as the connection order in the first detection execution plan;
[0033] Multi-table join query processing is performed based on the second detection execution plan.
[0034] The present application provides a machine-readable storage medium, wherein a plurality of computer instructions are stored on the machine-readable storage medium; when the computer instructions are executed, the following processing is performed:
[0035] Generate a first sample execution plan according to a sample multi-table join query request;
[0036] Inputting a first sample feature corresponding to the first sample execution plan into an initial network model, and obtaining a second sample feature by the initial network model according to the first sample feature;
[0037] generating a second sample execution plan based on the second sample feature; wherein a connection order in the second sample execution plan is different from a connection order in the first sample execution plan;
[0038] The initial network model is trained based on the performance of the first sample execution plan and the performance of the second sample execution plan to obtain a trained target network model.
[0039] The present application provides a machine-readable storage medium, wherein a plurality of computer instructions are stored on the machine-readable storage medium; when the computer instructions are executed, the following processing is performed:
[0040] Generate a first detection execution plan according to a detection multi-table connection query request;
[0041] Inputting a first detection feature corresponding to the first detection execution plan into a trained target network model, and obtaining a second detection feature by the target network model according to the first detection feature;
[0042] Generate a second detection execution plan based on the second detection feature; wherein the connection order in the second detection execution plan is different from or the same as the connection order in the first detection execution plan;
[0043] Multi-table join query processing is performed based on the second detection execution plan.
[0044] Based on the above technical solution, in an embodiment of the present application, the first detection feature corresponding to the first detection execution plan can be input into the trained target network model, and the target network model obtains the second detection feature based on the first detection feature, and generates a second detection execution plan based on the second detection feature, thereby obtaining a second detection execution plan with better performance, and performing multi-table connection query processing based on the second detection execution plan. The above method can obtain an execution plan with better performance through the target network model, thereby finding a better execution plan, and optimizing the execution plan of the database, improving the efficiency of multi-table connection queries in the database, and then obtaining better execution performance, that is, a shorter execution delay, thereby improving the execution performance of the query. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments of the present application or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For ordinary technicians in this field, other drawings can also be obtained based on these drawings of the embodiments of the present application.
[0046] Figure 1It is a flowchart of a method for processing multi-table connections in one implementation of the present application;
[0047] Figure 2 It is a flowchart of a method for processing multi-table connections in one implementation of the present application;
[0048] Figure 3 It is a schematic diagram of an application scenario of an embodiment of the present application;
[0049] Figure 4 is a schematic diagram of a training process in one embodiment of the present application;
[0050] Figure 5 is a schematic diagram of a DQN model in one embodiment of the present application;
[0051] Figure 6 is a schematic diagram of a detection process in one embodiment of the present application;
[0052] Fig. 7A and Figure 7B is a structural diagram of a processing device for connecting multiple meters in one embodiment of the present application;
[0053] Figure 8 It is a schematic diagram of the structure of a processing device with multiple meters connected in one embodiment of the present application. DETAILED DESCRIPTION
[0054] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, rather than limiting the present application. The singular forms of "a", "said" and "the" used in the present application and claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to any or all possible combinations of one or more associated listed items.
[0055] It should be understood that, although the terms first, second, third, etc. may be used to describe various information in the embodiments of the present application, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, in addition, the word "if" used may be interpreted as "at..." or "when..." or "in response to determination".
[0056] In the embodiment of the present application, a method for processing multi-table connections is proposed, which can be applied to any type of device. Figure 1 FIG. 1 is a flow chart of the method, which may include:
[0057] Step 101: Generate a first sample execution plan according to a sample multi-table join query request.
[0058] Step 102: input the first sample feature corresponding to the first sample execution plan into the initial network model, and the initial network model obtains the second sample feature according to the first sample feature.
[0059] Exemplarily, before step 102, a first sample feature may be generated based on the first sample execution plan, and the first sample feature may include but is not limited to: information feature and / or structural feature. For example, the first sample execution plan may include multiple operation nodes, the information feature is used to represent the node information of a single operation node, and the structural feature is used to represent the relationship information between the operation nodes.
[0060] Exemplarily, the information feature may include but is not limited to at least one of the following vectors:
[0061] Table vector; the first sample execution plan may include a data table identifier, the position corresponding to the data table identifier in the table vector is a first value (such as 1, etc.), and the position not corresponding to the data table identifier in the table vector is a second value (such as 0, etc.). The table vector may have N positions, N is the total number of data tables in the database, and the N positions of the table vector correspond one-to-one to the N data tables.
[0062] Column vector; the first sample execution plan may include a column identifier, the position corresponding to the column identifier in the column vector is a first value, and the position not corresponding to the column identifier in the column vector is a second value. The column vector has M positions, M is the total number of columns of each data table in the database (i.e., the total number of all columns of all data tables), and the M positions of the column vector correspond to the M columns one by one.
[0063] The operation type vector of the operation node, that is, each operation node corresponds to an operation type vector. For the operation type vector of each operation node, the operation type vector may have P operation type positions and Q operation object positions, P is the total number of operation types, P operation type positions correspond to P operation types one by one, Q is the total number of operation objects, Q operation object positions correspond to Q operation objects one by one. Based on this, the position corresponding to the operation type of the operation node in the P operation type positions is the first value, and the position not corresponding to the operation type of the operation node in the P operation type positions is the second value. The position corresponding to the operation object of the operation node in the Q operation object positions is the first value, and the position not corresponding to the operation object of the operation node in the Q operation object positions is the second value.
[0064] Exemplarily, each operation node in the first sample execution plan has a unique node identifier, that is, each operation node corresponds to a node identifier. Based on this, the above structural features may include but are not limited to the relationship vectors of each operation node. For the relationship vector of each operation node, the relationship vector of the operation node may include but is not limited to: the node identifier of the operation node, the node identifier of the parent node (i.e., the upstream node) of the operation node, and the node identifier of the child node (i.e., the downstream node) of the operation node.
[0065] Step 103: Generate a second sample execution plan based on the second sample feature; wherein the connection order in the second sample execution plan is different from the connection order in the first sample execution plan.
[0066] Exemplarily, after the first sample feature corresponding to the first sample execution plan is input into the initial network model, the initial network model can adjust the connection order in the first sample execution plan according to the first sample feature to obtain the second sample feature corresponding to the second sample execution plan. Therefore, after generating the second sample execution plan based on the second sample feature, the connection order in the second sample execution plan is different from the connection order in the first sample execution plan, thereby achieving the purpose of optimizing the connection order.
[0067] Step 104: Train the initial network model based on the performance of the first sample execution plan and the performance of the second sample execution plan to obtain a trained target network model. Exemplarily, the initial network model is a network model for optimizing the connection sequence in the execution plan, and the target network model is also a network model for optimizing the connection sequence in the execution plan.
[0068] In a possible implementation, it may be determined whether the current initial network model has converged.
[0069] If not, the network parameters of the initial network model can be adjusted based on the performance of the first sample execution plan and the performance of the second sample execution plan to obtain an adjusted initial network model; based on the adjusted initial network model, return to execute the operation of inputting the first sample features corresponding to the first sample execution plan into the initial network model; wherein the performance of the second sample execution plan can be an estimated performance, or a performance collected when executing the second sample execution plan.
[0070] If yes, the current initial network model is determined as the trained target network model.
[0071] In a possible implementation, after obtaining the trained target network model, the target network model can be deployed, based on which a multi-table connection query request can be obtained, a first detection execution plan is generated according to the multi-table connection query request, and a first detection feature is generated based on the first detection execution plan. Then, the first detection feature is input into the target network model, and the target network model obtains a second detection feature according to the first detection feature. A second detection execution plan is generated based on the second detection feature; wherein the connection order in the second detection execution plan is different from or the same as the connection order in the first detection execution plan. Then, multi-table connection query processing is performed based on the second detection execution plan.
[0072] Exemplarily, the first detection feature may include but is not limited to: information features and / or structural features; the first detection execution plan may include multiple operation nodes, the information feature may be used to represent the node information of a single operation node, and the structural feature may be used to represent the relationship information between the operation nodes.
[0073] In one example, the above execution order is just an example given for the convenience of description. In practical applications, the execution order between the steps can also be changed, and there is no limitation on this execution order. Moreover, in other embodiments, the steps of the corresponding method are not necessarily executed in the order shown and described in this specification, and the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; multiple steps described in this specification may also be combined into a single step for description in other embodiments.
[0074] Based on the above technical solution, in an embodiment of the present application, the first detection feature corresponding to the first detection execution plan can be input into the trained target network model, and the target network model obtains the second detection feature based on the first detection feature, and generates a second detection execution plan based on the second detection feature, thereby obtaining a second detection execution plan with better performance, and performing multi-table connection query processing based on the second detection execution plan. The above method can obtain an execution plan with better performance through the target network model, thereby finding a better execution plan, and optimizing the execution plan of the database, improving the efficiency of multi-table connection queries in the database, and then obtaining better execution performance, that is, a shorter execution delay, thereby improving the execution performance of the query.
[0075] Based on the same application concept as the above method, another method for processing multi-table connections is also proposed in the embodiment of the present application, see Figure 2 FIG. 1 is a flow chart of the method, which may include:
[0076] Step 201: Generate a first detection execution plan according to a detection multi-table connection query request.
[0077] Step 202: input the first detection feature corresponding to the first detection execution plan into the trained target network model, and the target network model obtains the second detection feature according to the first detection feature.
[0078] Exemplarily, before step 202, a first detection feature may be generated based on the first detection execution plan, and the first detection feature may include but is not limited to: information features and / or structural features. For example, the first detection execution plan may include multiple operation nodes, the information feature is used to represent the node information of a single operation node, and the structural feature is used to represent the relationship information between the operation nodes.
[0079] Exemplarily, the information feature may include but is not limited to at least one of the following vectors:
[0080] Table vector; the first detection execution plan may include a data table identifier, the position corresponding to the data table identifier in the table vector is a first value (such as 1, etc.), and the position not corresponding to the data table identifier in the table vector is a second value (such as 0, etc.). The table vector may have N positions, N is the total number of data tables in the database, and the N positions of the table vector correspond one-to-one to the N data tables.
[0081] Column vector; the first detection execution plan may include a column identifier, the position corresponding to the column identifier in the column vector is a first value, and the position not corresponding to the column identifier in the column vector is a second value. Wherein, the column vector has M positions, M is the total number of columns of each data table in the database (i.e., the total number of all columns of all data tables), and the M positions of the column vector correspond one-to-one to the M columns.
[0082] The operation type vector of the operation node, that is, each operation node corresponds to an operation type vector. For the operation type vector of each operation node, the operation type vector may have P operation type positions and Q operation object positions, P is the total number of operation types, P operation type positions correspond to P operation types one by one, Q is the total number of operation objects, Q operation object positions correspond to Q operation objects one by one. Based on this, the position corresponding to the operation type of the operation node in the P operation type positions is the first value, and the position not corresponding to the operation type of the operation node in the P operation type positions is the second value. The position corresponding to the operation object of the operation node in the Q operation object positions is the first value, and the position not corresponding to the operation object of the operation node in the Q operation object positions is the second value.
[0083] Exemplarily, each operation node in the first detection execution plan has a unique node identifier, that is, each operation node corresponds to a node identifier. Based on this, the above structural features may include but are not limited to the relationship vectors of each operation node. For the relationship vector of each operation node, the relationship vector of the operation node may include but is not limited to: the node identifier of the operation node, the node identifier of the parent node (i.e., the upstream node) of the operation node, and the node identifier of the child node (i.e., the downstream node) of the operation node.
[0084] Step 203, generating a second detection execution plan based on the second detection feature; wherein the connection order in the second detection execution plan is different from or the same as the connection order in the first detection execution plan.
[0085] Exemplarily, after the first detection feature corresponding to the first detection execution plan is input into the target network model, if the first detection execution plan is not the optimal execution plan (i.e., the connection sequence in the first detection execution plan is not the optimal connection sequence), the target network model can adjust the connection sequence in the first detection execution plan according to the first detection feature to obtain the second detection feature corresponding to the second detection execution plan. Therefore, after the second detection execution plan is generated based on the second detection feature, the connection sequence in the second detection execution plan can be different from the connection sequence in the first detection execution plan, thereby achieving the purpose of optimizing the connection sequence. If the first detection execution plan is already the optimal execution plan (i.e., the connection sequence in the first detection execution plan is already the optimal connection sequence), the target network model does not adjust the connection sequence in the first detection execution plan, and directly uses the first detection feature as the second detection feature. Therefore, after the second detection execution plan is generated based on the second detection feature, the connection sequence in the second detection execution plan can be the same as the connection sequence in the first detection execution plan.
[0086] Step 204: Perform multi-table join query processing based on the second detection execution plan.
[0087] In one example, the above execution order is just an example given for the convenience of description. In practical applications, the execution order between the steps can also be changed, and there is no limitation on this execution order. Moreover, in other embodiments, the steps of the corresponding method are not necessarily executed in the order shown and described in this specification, and the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; multiple steps described in this specification may also be combined into a single step for description in other embodiments.
[0088] Based on the above technical solution, in an embodiment of the present application, the first detection feature corresponding to the first detection execution plan can be input into the trained target network model, and the target network model obtains the second detection feature based on the first detection feature, and generates a second detection execution plan based on the second detection feature, thereby obtaining a second detection execution plan with better performance, and performing multi-table connection query processing based on the second detection execution plan. The above method can obtain an execution plan with better performance through the target network model, thereby finding a better execution plan, and optimizing the execution plan of the database, improving the efficiency of multi-table connection queries in the database, and then obtaining better execution performance, that is, a shorter execution delay, thereby improving the execution performance of the query.
[0089] The following describes the processing method of the above multi-table connection in combination with specific application scenarios.
[0090] See also Figure 3 As shown, it is a schematic diagram of the application scenario of an embodiment of the present application. The client can be an APP (Application) included in a terminal device (such as a PC (Personal Computer), a laptop computer, a mobile terminal), or it can be a browser included in the terminal device, and there is no limitation on this.
[0091] The query device is used to implement the multi-table connection processing method of the embodiment of the present application. Since the user data is stored in multiple databases (i.e., data sources), the query device is used to connect to each database and read data from each database to support cross-database data processing. When using the query device, the user usually uses a query language (such as SQL) to describe the query task, and then the query device executes it. The query device has a query optimization function and can automatically select a reasonable execution plan to process user queries.
[0092] For multiple databases, these databases can be databases of the same type or databases of different types. In addition, these databases can be relational databases or non-relational databases. For example, for each database, the type of this database can include but is not limited to: OSS (Object Storage Service), Table Store, HBase (Hadoop Database), HDFS (Hadoop Distributed File System), MySQL (i.e. relational database), RDS (Relational Database Service), DRDS (Distribute Relational Database Service), RDBMS (Relational Database Management System), SQL Server (i.e. relational database), PostgreSQL (i.e. object-relational database), MongoDB (i.e. database based on distributed file storage), etc.
[0093] In the application scenario of database, the query device includes a query optimizer (also called a parser) and an executor. The query optimizer is used to receive SQL query requests and automatically generate an execution plan corresponding to the SQL query request. The executor is used to execute the execution plan to realize the data query function.
[0094] Multi-table join query is a typical application of SQL and is frequently used in databases. Multi-table join query involves multiple data tables. Different join orders of multiple data tables correspond to different execution plans, and the performance of these execution plans varies greatly. Therefore, it is necessary to select the optimal execution plan from these execution plans.
[0095] For example, a multi-table join query involves data table 1, data table 2, and data table 3. The query optimizer can generate execution plans 1, 2, and 3. In execution plan 1, first, a join operation is performed on data table 1 and data table 2 to obtain intermediate data table A. Then, a join operation is performed on intermediate data table A and data table 3 to obtain a result data table, and query operations are performed based on the result data table. In execution plan 2, first, a join operation is performed on data table 1 and data table 3 to obtain intermediate data table B. Then, a join operation is performed on intermediate data table B and data table 2 to obtain a result data table, and query operations are performed based on the result data table. In execution plan 3, first, a join operation is performed on data table 2 and data table 3 to obtain intermediate data table C. Then, a join operation is performed on intermediate data table C and data table 1 to obtain a result data table, and query operations are performed based on the result data table.
[0096] Obviously, in Execution Plan 1, Execution Plan 2, and Execution Plan 3, the connection order in different execution plans may be different, resulting in large differences in the performance of different execution plans.
[0097] In the related art, in order to select the best execution plan from among execution plan 1, execution plan 2 and execution plan 3, the performance of execution plan 1, the performance of execution plan 2 and the performance of execution plan 3 can be estimated. If the performance of execution plan 1 is the best, execution plan 1 is used as the best execution plan. However, when there are a large number of execution plans (such as hundreds or even thousands), it takes a long time to estimate the performance of each execution plan in turn, and the estimation result may be inaccurate, resulting in the inability to select the execution plan with the best performance.
[0098] In response to the above findings, a connection order optimization method based on deep reinforcement learning (DRL) is proposed in this embodiment, which can use deep reinforcement learning to select the connection order, and can find the optimal connection order based on past experience with less computational complexity. Deep reinforcement learning is good at perceiving the distribution and correlation of data. Using deep reinforcement learning to select the connection order can overcome the incorrect assumptions about real data in traditional optimization methods. Deep reinforcement learning is good at decision-making, and can optimize future decision-making capabilities based on rewards and punishments during the decision-making process. Therefore, the execution plans of different connection orders can be used as optimizable states, adjusting the connection order can be used as an optional action, and the performance of the execution plan (such as execution delay) can be used as the corresponding reward. The model's future action decisions are optimized based on the size of the reward.
[0099] In this embodiment, the features can be divided into information features and structural features. The information features represent the basic information of a single operation node in the execution plan, and the structural features represent the parent-child relationship information between the operation nodes in the execution plan. That is, the structural features are obtained by feature encoding the tree structure of the execution plan, and the structural features effectively retain the tree structure information of the execution plan. The feature information of any execution plan can be effectively represented by the information features and the structural features, and the state information of the execution plan and the relationship between the return and the action can be fully utilized to optimize the connection order, thereby improving the execution performance of the query.
[0100] This embodiment involves a training process and a detection process. In the training process, the initial network model is trained based on a multi-table connection query request to obtain a trained target network model. In the detection process, an execution plan is obtained based on the trained target network model. The training process and the detection process are described below. For the sake of distinction, this article refers to the multi-table connection query request in the training process as a sample multi-table connection query request, the execution plan in the training process as a sample execution plan, and the features in the training process as sample features. The multi-table connection query request in the detection process is referred to as a detection multi-table connection query request, the execution plan in the detection process is referred to as a detection execution plan, and the features in the detection process are referred to as detection features.
[0101] See also Figure 4 As shown in the figure, it is a schematic diagram of the training process. The optimization framework process can be pre-built. The components from left to right can be divided into three parts: database instance, feature encoding, and DQN model. The database instance can be a database such as PostgreSQL and MySQL, which is used for data storage, SQL parsing, query execution, etc. Feature encoding can use information features and structural features to represent a query plan tree, which is used as the feature input of the Tree-LSTM network in the DQN model. The DQN model is divided into an agent and an environment. The agent generates actions and is the decision maker of the action. The environment adjusts the connection order according to the action of the agent and evaluates each action. See Figure 4 As shown, the training process may include the following steps:
[0102] Step s11: The query optimizer obtains a sample multi-table join query request.
[0103] Exemplarily, there are a large number of SQL query requests in the history log, and a multi-table connection query request (i.e., an SQL multi-table connection query request, which is an SQL connection query request involving multiple data tables) can be selected from these SQL query requests and recorded as a sample multi-table connection query request.
[0104] For example, sample multi-table connection query requests can be selected from these SQL query requests through regular matching. Of course, the implementation method of regular matching is only an example. For example, sample multi-table connection query requests can be selected by users, and there is no restriction on this. As long as sample multi-table connection query requests can be selected from SQL query requests, the sample multi-table connection query requests can be used as training data for the initial network model.
[0105] In actual applications, similar SQL query requests with different predicates may appear in historical logs, for example, [SPJ structure]WHERE a<100 and [SPJ structure]WHERE a<110. The execution plans of the above two SQL query requests are basically the same, and the execution delays are also very close. If these two SQL query requests are used as sample multi-table join query requests to participate in model training, the training results of the two SQL query requests are consistent, which will not improve the training performance of the model. However, it will increase the training time of the model. Therefore, it is necessary to avoid using these two SQL query requests as sample multi-table join query requests. Based on this, a new SQL query request [SPJ structure]WHERE a<# can be generated based on these two SQL query requests, and this SQL query request can be used as a sample multi-table join query request to participate in model training.
[0106] Step s12: The query optimizer converts the sample multi-table join query request into a first sample execution plan.
[0107] Exemplarily, the number of sample multi-table connection query requests can be multiple. For each sample multi-table connection query request, the sample multi-table connection query request is converted into a first sample execution plan, that is, each sample multi-table connection query request corresponds to a first sample execution plan. For the convenience of description, in the subsequent embodiments, a first sample execution plan corresponding to a sample multi-table connection query request is taken as an example.
[0108] Exemplarily, the sample multi-table join query request is a SQL-type query request written by a user. The query optimizer can convert this sample multi-table join query request into a machine-executable first sample execution plan. There is no restriction on this conversion process. The first sample execution plan describes a specific execution step.
[0109] Exemplarily, the first sample execution plan may include multiple operation nodes, each of which may represent a calculation step. For example, scanning operation nodes (such as Seq Scan, Index Scan, Index Only Scan, Bitmap Scan, etc.); connection operation nodes (such as Join, Nested Loop, Hash Join, Merge Join, etc.); materialization operation nodes (such as Materialize); sorting operation nodes (such as Sort); grouping operation nodes (such as Group); aggregation operation nodes (such as Aggregate); filtering operation nodes (such as Filter); projection operation nodes (such as Projection); appending operation nodes (such as Append), etc. Of course, the above are just a few examples of operation nodes, and other types of operation nodes may also be included, without limitation.
[0110] In a possible implementation, a tree structure may be used to arrange the multiple operation nodes of the first sample execution plan, and there is no limitation on the arrangement method. After the multiple operation nodes of the first sample execution plan are arranged, the process of executing the first sample execution plan is to start from the lowest level operation node (i.e., the bottom level operation node) of the first sample execution plan and execute each operation node in turn.
[0111] For example, the sample multi-table join query request involves query operations on data table 1, data table 2, and data table 3. The query optimizer can convert the sample multi-table join query request into a first sample execution plan. The first sample execution plan can be found in Figure 4 As shown, the first sample execution plan may include multiple operation nodes, and the multiple operation nodes of the first sample execution plan are arranged in a tree structure.
[0112] exist Figure 4 In the example, the operation node at the position of data table 1 is recorded as operation node 1, which can be a scan operation node, indicating that the data in data table 1 needs to be scanned. The operation node at the position of data table 2 is recorded as operation node 2, which can be a scan operation node, indicating that the data in data table 2 needs to be scanned. The operation node at the position of connection 1 is recorded as operation node 3, which can be a join operation node (i.e., Join node), indicating that a join operation needs to be performed on data table 1 and data table 2 to obtain an intermediate data table A. The operation node at the position of data table 3 is recorded as operation node 4, which can be a scan operation node, indicating that the data in data table 3 needs to be scanned. The operation node at the position of connection 2 is recorded as operation node 5, which can be a join operation node, indicating that a join operation needs to be performed on intermediate data table A and data table 3 to obtain a result data table, and subsequent query operations are performed based on the result data table.
[0113] Step s13: The query optimizer generates a first sample feature based on the first sample execution plan. The first sample feature may include but is not limited to: information feature (also called vector list feature) and / or structure feature (also called tree dictionary feature). Exemplarily, the information feature is used to represent node information of a single operation node, and the structure feature is used to represent relationship information between operation nodes.
[0114] After the query optimizer obtains the first sample execution plan, it performs feature encoding on the first sample execution plan to obtain information features and structural features. Feature encoding refers to extracting features from input information (the first sample execution plan in this article) and converting it into an input vector acceptable to the model (information features and structural features in this article).
[0115] The following describes the process of generating the first sample feature in combination with a specific application scenario.
[0116] Before step s13, all data tables in all databases may be numbered. Assuming there are 10 data tables in all databases, the 10 data tables are numbered 1-10, with number 1 corresponding to data table 1, number 2 corresponding to data table 2, and so on, number 10 corresponding to data table 10.
[0117] Before step s13, all columns in all data tables can be numbered. Assuming that there are 10 data tables in total and each data table has 3 columns, there are 30 columns in total. The 30 columns are numbered 1-30, with number 1 corresponding to column 1 of data table 1, number 2 corresponding to column 2 of data table 1, number 3 corresponding to column 3 of data table 1, number 4 corresponding to column 1 of data table 2, number 5 corresponding to column 2 of data table 2, number 6 corresponding to column 3 of data table 2, and so on. Number 30 corresponds to column 3 of data table 10.
[0118] In the above embodiment, data table 1 refers to the table name of the data table, such as the teacher table, the student table, etc. For the convenience of description, the table name of the data table is recorded as data table 1 in this article. Similarly, data table 2, data table 3, etc. are also table names of the data table. Column 1 of data table 1 refers to the column name of the first column of data table 1, such as name, ID number, etc. For the convenience of description, the column name of data table 1 is recorded as column 1 of data table 1 in this article. Similarly, column 2 of data table 1, column 3 of data table 1, column 1 of data table 2, etc. are also column names.
[0119] Before step s13, all operation types for all databases can be numbered. Assuming that there are 9 operation types in total, the numbers of these 9 operation types are 1-9, with number 1 corresponding to operation type 1, number 2 corresponding to operation type 2, and so on, number 9 corresponding to operation type 9. For example, operation type 1 is a scan operation type, operation type 2 is a join operation type, operation type 3 is a materialization operation type, operation type 4 is a sorting operation type, operation type 5 is a grouping operation type, operation type 6 is an aggregation operation type, operation type 7 is a filtering operation type, operation type 8 is a projection operation type, and operation type 9 is an append operation type. Of course, the above are only examples of operation types and are not limited thereto.
[0120] In step s13, the query optimizer may perform feature encoding on the first sample execution plan to obtain information features, where the information features include a table vector, a column vector, and an operation type vector of each operation node.
[0121] Exemplarily, assuming that the first sample execution plan involves query operations on data table 1, data table 2, and data table 3, an example of a table vector can be shown in Table 1, where the positions corresponding to data table 1, data table 2, and data table 3 in the table vector are first values (such as 1), and other positions are second values (such as 0). As can be seen from Table 1, since the total number of all data tables in the database is 10, there are a total of 10 positions in the table vector, and the 10 positions of the table vector correspond one-to-one to the 10 data tables.
[0122] Table 1
[0123] No. 1 No. 2 No. 3 No. 4 No. 5 No. 6 No. 7 No. 8 No. 9 No. 10 1 1 1 0 0 0 0 0 0 0
[0124] Exemplarily, assuming that the first sample execution plan involves query operations on columns 1 and 2 of data table 1, columns 1 and 3 of data table 2, and column 3 of data table 3, an example of a column vector is shown in Table 2, where the positions corresponding to column 1 (corresponding to number 1) of data table 1, column 2 (corresponding to number 2) of data table 1, column 1 (corresponding to number 4) of data table 2, column 3 (corresponding to number 6) of data table 2, and column 3 (corresponding to number 9) of data table 3 in the column vector are first values (such as 1), and the other positions are second values (such as 0). As can be seen from Table 2, since the total number of all columns of all data tables is 30, there can be a total of 30 positions in the column vector, and the 30 positions of the column vector correspond one-to-one to the 30 columns.
[0125] Table 2
[0126] No. 1 No. 2 No. 3 No. 4 No. 5 No. 6 No. 7 No. 8 No. 9 No. 10 1 1 0 1 0 1 0 0 1 0 No. 11 No. 12 No. 13 No. 14 No. 15 No. 16 No. 17 No. 18 No. 19 No. 20 0 0 0 0 0 0 0 0 0 0 No. 21 No. 22 No. 23 No. 24 No. 25 No. 26 No. 27 No. 28 No. 29 No. 30 0 0 0 0 0 0 0 0 0 0
[0127] Exemplarily, the first sample execution plan includes 5 operation nodes, and the information feature includes an operation type vector of each operation node. Since the total number of operation types is 9, and the total number of operation objects (taking the columns of a data table as operation objects as an example, the total number of operation objects is the total number of all columns of all data tables) is 30, the operation type vector has 9 operation type positions and 30 operation object positions, and the 9 operation type positions correspond one-to-one to the 9 operation types, and the 30 operation object positions correspond one-to-one to the 30 columns.
[0128] See also Figure 4 As shown, for operation node 1, the operation type of operation node 1 is a scan operation type, and the operation object of operation node 1 is column 1 and column 2 of data table 1. Therefore, an example of the operation type vector of operation node 1 is shown in Table 3. The position corresponding to the "scan operation type" in the operation type vector is the first value (such as 1), the position corresponding to the "column 1 and column 2 of data table 1" in the operation type vector is the first value (such as 1), and the other positions are the second value (such as 0).
[0129] Table 3
[0130]
[0131]
[0132] The operation type vector of operation node 2 is similar to the operation type vector of operation node 1, and will not be described in detail here. For operation node 3, the operation type of operation node 3 is a connection operation type, and the operation objects of operation node 3 are columns 1 and 2 of data table 1, and columns 1 and 3 of data table 2. Therefore, an example of the operation type vector of operation node 3 is shown in Table 4, and the position corresponding to the "connection operation type" in the operation type vector is the first value, and the position corresponding to "columns 1 and 2 of data table 1, and columns 1 and 3 of data table 2" in the operation type vector is the first value, and the other positions are the second value.
[0133] Table 4
[0134]
[0135] The operation type vector of operation node 4 is similar to the operation type vector of operation node 1, and will not be described in detail here. For operation node 5, the operation type of operation node 5 is a connection operation type, and the operation objects of operation node 5 are columns 1 and 2 of data table 1, columns 1 and 3 of data table 2, and column 3 of data table 3. Therefore, the position corresponding to the "connection operation type" in the operation type vector of operation node 3 is the first value, the position corresponding to "columns 1 and 2 of data table 1, columns 1 and 3 of data table 2, and column 3 of data table 3" in the operation type vector is the first value, and the other positions are the second value.
[0136] In the above embodiment, since operation node 3 is the parent node of operation node 1 and operation node 2, the operation object of operation node 1 and the operation object of operation node 2 are used as the operation object of operation node 3. Since operation node 5 is the parent node of operation node 3 and operation node 4, the operation object of operation node 3 and the operation object of operation node 4 are used as the operation object of operation node 5.
[0137] To summarize, the information features include table vector (Table 1), column vector (Table 2), operation type vector of operation node 1 (Table 3), operation type vector of operation node 2, operation type vector of operation node 3 (Table 4), operation type vector of operation node 4, and operation type vector of operation node 5.
[0138] For each operation node in the first sample execution plan, the information feature includes an operation type vector of the operation node, which can represent the operation type and operation object of the operation node, and the operation object is usually a column in a data table, or data transmitted from a lower-level node.
[0139] The above encoding method of setting a certain position to the first value or the second value is a one-hot encoding method. In practical applications, other encoding methods may also be used, and there is no limitation to this.
[0140] In step s13, the query optimizer may perform feature encoding on the first sample execution plan to obtain structural features, which may include but are not limited to a relationship vector of each operation node.
[0141] Exemplarily, the first sample execution plan includes 5 operation nodes, and the structural feature includes the relationship vectors of the 5 operation nodes. The relationship vector of operation node 1 includes: the node identifier of operation node 1, and the node identifier of the parent node (operation node 3) of operation node 1. The relationship vector of operation node 2 includes: the node identifier of operation node 2, and the node identifier of the parent node (operation node 3) of operation node 2. The relationship vector of operation node 3 includes: the node identifier of operation node 3, the node identifier of the parent node (operation node 5) of operation node 3, and the node identifiers of the child nodes (operation node 1 and operation node 2) of operation node 3. The relationship vector of operation node 4 includes: the node identifier of operation node 4, and the node identifier of the parent node (operation node 5) of operation node 4. The relationship vector of operation node 5 includes: the node identifier of operation node 5, and the node identifiers of the child nodes (operation node 3 and operation node 4) of operation node 5.
[0142] Obviously, based on the relationship vectors of the above five operation nodes, the positional relationship between the operation nodes can be obtained, and the Figure 4 The first sample execution plan shown is an execution plan with a tree structure.
[0143] In summary, the query optimizer can obtain information features and structural features by encoding the features of the first sample execution plan. The information feature is a vector list consisting of a table vector, a column vector, and an operation type vector of each operation node, and the structural feature is a relationship vector of each operation node. Obviously, since the information feature cannot restore the execution plan of the tree structure, the information feature is combined with the structural feature (used to record the information of the child node and the parent node) to restore the execution plan of the tree structure.
[0144] In summary, the database instance that the user needs to optimize the connection can be determined first, and the table name, column name, operation type and other information in the database instance can be numbered. For an operation node in the query plan tree (i.e., the sample execution plan), it indicates the operation type, such as Hash Join, Index Scan, Group, etc. In addition, there is an operation object, which is usually a column relationship in a table, or data transmitted from a lower node. After these information numbers, the operation node can be one-hot encoded, that is, if the corresponding operation, table, and column are involved in the vector, the corresponding position of the vector is 1, and the information of the child node needs to be passed upward to its father node. After the operation nodes of the query plan tree are post-order traversed, the vector arrangement obtained corresponds to the vector list of the model network (i.e., the information feature in the above embodiment), and the dimension of a single vector is the sum of the number of tables, columns, and operation types in the database instance. If DDL operation is required, a little space can be reserved for the vector dimension in advance. If there is only a vector list, the information of the vector list cannot be restored to the corresponding tree structure, so it is also necessary to record the information of the parent node and child node of the operation, and store it in a dictionary manner, corresponding to the tree dictionary (i.e., the structural feature in the above embodiment). The tree dictionary and vector list fully represent a query plan tree, which are the feature inputs of the Tree-LSTM network.
[0145] Step s14: The query optimizer inputs the first sample features (ie, information features and structural features) into the initial network model, and the initial network model obtains the second sample features based on the first sample features.
[0146] Exemplarily, after the first sample feature corresponding to the first sample execution plan is input into the initial network model, the initial network model can adjust the connection order in the first sample execution plan according to the first sample feature to obtain the second sample feature corresponding to the second sample execution plan, that is, the connection order in the second sample execution plan is different from the connection order in the first sample execution plan.
[0147] See also Figure 4 As shown, the DQN (Deep-Q-learning) model is also called a reinforcement learning model, which can learn knowledge in the decision-making process. The DQN model may include but is not limited to a Tree-LSTM (Tree Long Short-Term Memory) network, an action execution module, and an evaluation module. The Tree-LSTM network is a deep learning network suitable for tasks with tree structure input.
[0148] In the embodiment of the present application, the initial network model can be a model of a Tree-LSTM network structure, that is, the Tree-LSTM network is used as the initial network model. Of course, the Tree-LSTM network is just an example and is not limited to this. The initial network model can be a model of any structure. This article takes the Tree-LSTM network as an example.
[0149] In summary, information features and structural features can be used as input features of the Tree-LSTM network.
[0150] See also Figure 4 As shown in Figure 1, the DQN model can be divided into an agent and an environment. The agent generates actions and is the decision maker of the actions. The environment can adjust the connection order according to the actions of the agent and evaluate each action. Figure 5 As shown in the figure, the implementation of the intelligent agent in the DQN model is shown. Its structure is a Tree-LSTM network. For each neural unit, the Tree-LSTM network contains an input gate, an output gate, a memory cell and a hidden layer state. The update of the gate vector and the memory cell of the Tree-LSTM network depends on the state of its child nodes, and each child node has a forget gate for the parent node, as shown in the following formula.
[0151]
[0152] In the above formula, {W, U, b} represents the network parameters (i.e., the network parameters that need to be adjusted during training), x and h are the input vector and hidden layer vector, l and n represent the child node number and the total number of children respectively. The above formula represents the output result of the forget gate of the kth child. This design allows the Tree-LSTM network to selectively memorize information from child nodes, thereby retaining its parent-child relationship characteristics.
[0153] Based on the above network structure, in this embodiment, after obtaining the information features and the structural features, the information features and the structural features can be input into the Tree-LSTM network, see Figure 5 As shown, in addition to the information features and structural features as the input of the Tree-LSTM network, there is also an input of a remaining state, which indicates whether optimization is still needed, that is, whether the optimization based on the first sample feature is completed.
[0154] After receiving the information features and structural features, the Tree-LSTM network uses its own network parameters to process the information features and structural features, and there is no restriction on this processing process. Based on the processing results, the Tree-LSTM network outputs an action, which indicates the connection number that needs to be adjusted, that is, how to adjust the information features and structural features. The adjustment process of the information features and structural features is actually to adjust the connection order in the execution plan, that is, to adjust the first sample feature corresponding to the first sample execution plan to the second sample feature corresponding to the second sample execution plan, and the connection order in the second sample execution plan is different from the connection order in the first sample execution plan. Based on the action output by the Tree-LSTM network, the action execution module adjusts the first sample feature to the second sample feature according to the action, and updates the remaining state information. The process of adjusting the first sample feature to the second sample feature is the process of adjusting the connection order.
[0155] The process of adjusting the first sample feature to the second sample feature is related to the structure and function of the Tree-LSTM network, and there is no restriction on this adjustment process. Figure 4 As shown, the first sample feature indicates that a connection operation is first performed on data table 1 and data table 2 to obtain an intermediate data table, and then a connection operation is performed on the intermediate data table and data table 3 to obtain a result data table. After the first sample feature is adjusted to the second sample feature, the second sample feature indicates that a connection operation is first performed on data table 1 and data table 3 to obtain an intermediate data table, and then a connection operation is performed on the intermediate data table and data table 2 to obtain a result data table.
[0156] Step s15: Generate a second sample execution plan based on the second sample feature; wherein the connection order in the second sample execution plan is different from the connection order in the first sample execution plan.
[0157] Exemplarily, after obtaining the second sample feature, the second sample feature is restored to a second sample execution plan. For example, the second sample feature includes a table vector (the same as the table vector of the first sample feature), a column vector (the same as the column vector of the first sample feature), an operation type vector of operation node 1 (the same as the operation type vector of operation node 1 of the first sample feature), an operation type vector of operation node 2 (the same as the operation type vector of operation node 4 of the first sample feature), an operation type vector of operation node 3 (the operation objects are data table 1 and data table 3, not data table 1 and data table 2), an operation type vector of operation node 4 (the same as the operation type vector of operation node 2 of the first sample feature), and an operation type vector of operation node 5 (the same as the operation type vector of operation node 5 of the first sample feature).
[0158] The second sample feature also includes a relationship vector of operation node 1, a relationship vector of operation node 2, a relationship vector of operation node 3, a relationship vector of operation node 4, and a relationship vector of operation node 5. These relationship vectors are similar to the five relationship vectors of the first sample feature and will not be repeated here.
[0159] To summarize, the second sample execution plan can be generated based on the table vector, column vector, operation type vector of each operation node, and relationship vector of each operation node of the second sample feature. There is no restriction on this generation process, which is the inverse process of generating the first sample feature according to the first sample execution plan.
[0160] See also Figure 4 As shown, an example of a second sample execution plan is shown, from Figure 4 It can be seen that the join order in the second sample execution plan is different from the join order in the first sample execution plan.
[0161] Step s16: Determine whether the current initial network model (ie, the Tree-LSTM network) has converged.
[0162] If it has not converged, it means that the Tree-LSTM network still needs to be trained, that is, the Tree-LSTM network has not been trained, and step s17 can be executed. If it has converged, it means that the Tree-LSTM network does not need to be trained, that is, the Tree-LSTM network has been trained, and step s18 can be executed.
[0163] Step s17: Based on the performance of the first sample execution plan and the performance of the second sample execution plan, the network parameters of the initial network model are adjusted to obtain an adjusted initial network model. Based on the adjusted initial network model, the process returns to step s14, that is, the first sample feature is input to the adjusted initial network model, so as to continue training the initial network model until the initial network model has converged.
[0164] Exemplarily, when returning to execute step s14, the first sample feature can be directly input into the adjusted initial network model, or the second sample feature can be updated to the first sample feature, and the updated first sample feature can be input into the adjusted initial network model to continue the optimization.
[0165] Exemplarily, when returning to execute step s14, a new sample multi-table connection query request can also be obtained, a new first sample execution plan is generated based on the new sample multi-table connection query request, and the first sample feature corresponding to the new sample execution plan is input into the adjusted initial network model to continue the optimization.
[0166] Exemplarily, multiple sample multi-table connection query requests can be obtained, and for each sample multi-table connection query request, the process of training the initial network model based on the sample multi-table connection query request can be called an optimization process based on the sample multi-table connection query request. When the initial network model has not converged, first determine whether the optimization process of the sample multi-table connection query request is finished. If it is not finished, it means that the initial network model still needs to be optimized based on the sample multi-table connection query request. Based on this, when returning to execute step s14, the above-mentioned second sample feature can be updated to the first sample feature, and the updated first sample feature is input to the adjusted initial network model, so as to continue the optimization. If it is finished, it means that the initial network model needs to be optimized based on a new sample multi-table connection query request. Based on this, when returning to execute step s14, a new sample multi-table connection query request can be obtained, a new first sample execution plan is generated based on the new sample multi-table connection query request, and the first sample feature corresponding to the new sample execution plan is input to the adjusted initial network model, so as to continue the optimization.
[0167] Step s18: determine the current initial network model as the trained target network model.
[0168] Exemplarily, in order to adjust the network parameters of the initial network model, it is necessary to obtain the performance of the first sample execution plan (such as execution delay, there is no restriction on this performance type, and the execution delay is taken as an example later) and the performance of the second sample execution plan. Regarding the execution delay of the first sample execution plan, when selecting a sample multi-table connection query request from the historical log, the execution delay corresponding to the sample multi-table connection query request can also be selected from the historical log. The execution delay is also the execution delay of the first sample execution plan.
[0169] Regarding the execution delay of the second sample execution plan, the execution delay of the second sample execution plan can be estimated, that is, the execution delay does not need to be actually executed, but the execution delay is directly estimated, and there is no restriction on this estimation method. Alternatively, the second sample execution plan can be actually executed by the executor, and the execution delay of the second sample execution plan can be collected during the actual execution of the second sample execution plan.
[0170] For example, the Tree-LSTM network may choose the wrong action, such as adjusting the connection number that has been adjusted. At this time, a negative reward should be given to the Tree-LSTM network to prevent such actions from happening again. Since the Tree-LSTM network does not have any prior knowledge in the early stage, it is easy to choose the wrong action or the negatively optimized action. If the real execution delay is used, a large number of sample execution plans need to be executed. The execution process of these sample execution plans takes a long time. Therefore, a pre-training phase can be designed. In the pre-training phase, each time the execution delay of the second sample execution plan is determined, the execution delay of the second sample execution plan can be directly estimated, that is, there is no need to actually execute the second sample execution plan.
[0171] After the pre-training phase, the Tree-LSTM network has basic optimization skills, but because the execution delay in the pre-training phase does not fully reflect the actual size of the execution delay, the actual execution delay can be further used for training, and this training process is called the real training phase. In the real training phase, each time the execution delay of the second sample execution plan is determined, the second sample execution plan needs to be actually executed and the execution delay of the second sample execution plan is collected, thereby reflecting the actual size of the execution delay.
[0172] Exemplarily, in the process of adjusting the network parameters of the initial network model based on the execution delay of the first sample execution plan and the execution delay of the second sample execution plan, if the execution delay of the first sample execution plan is better than the execution delay of the second sample execution plan, it means that the execution delay of the adjusted second sample execution plan has increased, that is, the initial network model has produced negative optimization in the adjustment action of the sample features, and it is necessary to avoid such actions from being selected. Based on the above principle, the network parameters of the initial network model are adjusted so that the initial network model no longer performs such actions. If the execution delay of the second sample execution plan is better than the execution delay of the first sample execution plan, it means that the execution delay of the adjusted second sample execution plan has decreased, that is, the initial network model has produced effective optimization in the adjustment action of the sample features, and future decisions should fully consider such actions. Based on the above principle, the network parameters of the initial network model are adjusted so that the initial network model continues to perform such actions. In summary, the effectiveness of the actions of the initial network model can be analyzed based on the execution delay of the first sample execution plan and the execution delay of the second sample execution plan, and then the network parameters of the initial network model are adjusted so that the initial network model maintains or abandons a certain action.
[0173] For example, the calculation formula of the reward return is as follows. The reward return can be determined based on the execution delay of the second sample execution plan and the execution delay of the first sample execution plan. The evaluation module adjusts the network parameters of the initial network model based on the reward return. Obviously, the larger the reward return, the better the effect achieved by the current action of the initial network model, and the initial network model should continue to perform such actions. The smaller the reward return, the worse the effect achieved by the current action of the initial network model, and the initial network model should give up performing such actions. The evaluation module can adjust the initial network model based on the above principles.
[0174]
[0175] In the above formula, S init and S final Indicates the execution delay of the first sample execution plan and the second sample execution plan. The difference between the logarithm of the execution delay and the logarithm of the execution delay is clipped to scale the data to a range more suitable for the initial network model to process. Exemplarily, a status check is performed after each action is completed to determine whether optimization is still required. If the status indicates that the optimization is not completed after a single action is executed, it indicates that the status is an intermediate state and the reward is 0; if the status indicates that the optimization is completed after a single action is executed, it indicates that the status is the final state and the final reward return is determined.
[0176] Exemplarily, in order to determine whether the initial network model has converged, the loss function of the initial network model can be pre-configured, as shown in the following formula. When the loss value of the loss function is less than a preset threshold, it means that the initial network model has converged, otherwise, it means that the initial network model has not converged. Of course, this loss function is just an example, and other methods can also be used without limitation. For example, when starting to train the initial network model, a timer can be set. When the timer times out, the training process ends, that is, it is directly determined that the initial network model has converged, thereby avoiding the training process consuming too much time.
[0177] Loss=(r+γmax a′ Q target (s′, a′)-Q online (s,a)) 2
[0178] In the above formula, γ can be a discount factor, which is used to design the initial network model to focus on the recent or long-term reward r, that is, r can be the above-mentioned reward return. s and a represent the current state and action respectively, and s' and a' represent the last state and action respectively. Therefore, the essence of the initial network model is to hope that the current Q estimate is infinitely close to the sum of the last Q target value and reward.
[0179] In summary, the initial network model can be trained based on the performance of the first sample execution plan and the performance of the second sample execution plan to obtain a trained target network model. The network structure of the target network model is similar to that of the initial network model, and will not be repeated here.
[0180] For example, when the data in the database undergoes significant changes, for example, a large number of add / delete / modify operations occur, the trained target network model may have certain errors. Therefore, based on the trained target network model, the optimized model of the latest database can be quickly obtained through a small number of trainings, and the optimized model of the latest database can be used as the trained target network model.
[0181] See also Figure 6 FIG. 4 is a schematic diagram of a detection process, which may include the following steps:
[0182] Step s21: The query optimizer obtains and detects a multi-table connection query request.
[0183] Specifically, the client may send a multi-table connection query request to the query device, and the query optimizer receives the multi-table connection query request and records the multi-table connection query request as a detection multi-table connection query request.
[0184] Step s22: The query optimizer converts the multi-table connection query request into a first detection execution plan. The first sample execution plan may include multiple operation nodes arranged in a tree structure.
[0185] Exemplarily, the implementation process of step s22 is similar to that of step s12, and will not be repeated here.
[0186] Step s23, the query optimizer generates a first detection feature based on the first detection execution plan, and the first detection feature may include but is not limited to: information feature (also known as vector list feature), and / or, structural feature (also known as tree dictionary feature). Exemplarily, the information feature is used to represent the node information of a single operation node, and the structural feature is used to represent the relationship information between operation nodes. The information feature may include but is not limited to at least one of the following vectors: table vector; column vector; operation type vector of each operation node. The structural feature may include but is not limited to: relationship vector of each operation node.
[0187] Exemplarily, the implementation process of step s23 is similar to that of step s13, and will not be repeated here.
[0188] Step s24: The query optimizer inputs the first detection feature into the trained target network model, and the target network model obtains the second detection feature based on the first detection feature.
[0189] Exemplarily, after the first detection feature corresponding to the first detection execution plan is input into the target network model, the target network model can adjust the connection order in the first detection execution plan according to the first detection feature to obtain the second detection feature corresponding to the second detection execution plan, that is, the connection order in the second detection execution plan is different from the connection order in the first detection execution plan.
[0190] Exemplarily, the implementation process of step s24 is similar to that of step s14, and will not be repeated here.
[0191] Step s25, generating a second detection execution plan based on the second detection feature; wherein the connection order in the second detection execution plan may be different from the connection order in the first detection execution plan.
[0192] Illustratively, the second detection execution plan is the target detection execution plan that needs to be executed.
[0193] Exemplarily, the implementation process of step s25 is similar to that of step s15, and will not be repeated here.
[0194] Step s26: The executor performs multi-table join query processing based on the second detection execution plan. That is, the executor implements the multi-table join query processing function by executing the second detection execution plan.
[0195] Based on the above technical solution, in an embodiment of the present application, the first detection feature corresponding to the first detection execution plan can be input into the trained target network model, and the target network model obtains the second detection feature according to the first detection feature, and generates a second detection execution plan based on the second detection feature, thereby obtaining a second detection execution plan with better performance, and performing multi-table connection query processing based on the second detection execution plan. The above method can obtain an execution plan with better performance through the target network model, thereby finding a better execution plan, and optimizing the execution plan of the database, improving the efficiency of multi-table connection queries of the database, and then obtaining better execution performance, that is, a shorter execution delay, thereby improving the execution performance of the query. The target network model selects effective optimization actions based on past experience to optimize the connection order to improve the execution efficiency of the query. The optimized execution plan can obtain better execution performance and shorter execution delay.
[0196] Based on the same application concept as the above method, the present application embodiment also provides a processing device for connecting multiple meters, such as Fig. 7A As shown, it is a structural diagram of the device, and the device includes:
[0197] A generation module 711 is used to generate a first sample execution plan according to a sample multi-table connection query request; an input module 712 is used to input a first sample feature corresponding to the first sample execution plan into an initial network model, and the initial network model obtains a second sample feature according to the first sample feature; the generation module 711 is also used to generate a second sample execution plan based on the second sample feature; the connection order in the second sample execution plan is different from the connection order in the first sample execution plan; a training module 713 is used to train the initial network model based on the performance of the first sample execution plan and the performance of the second sample execution plan to obtain a trained target network model.
[0198] The generating module 711 is further configured to generate the first sample feature based on the first sample execution plan; wherein the first sample feature includes an information feature and / or a structural feature;
[0199] The first sample execution plan includes multiple operation nodes, the information feature is used to represent the node information of a single operation node, and the structural feature is used to represent the relationship information between the operation nodes.
[0200] The training module 713 trains the initial network model based on the performance of the first sample execution plan and the performance of the second sample execution plan to obtain the trained target network model and is specifically used to: determine whether the current initial network model has converged;
[0201] If not, adjusting the network parameters of the initial network model based on the performance of the first sample execution plan and the performance of the second sample execution plan to obtain an adjusted initial network model; based on the adjusted initial network model, returning to execute the operation of inputting the first sample feature corresponding to the first sample execution plan into the initial network model; wherein the performance of the second sample execution plan is an estimated performance, or a performance collected when executing the second sample execution plan;
[0202] If yes, the current initial network model is determined as the trained target network model.
[0203] Based on the same application concept as the above method, the present application embodiment also provides a processing device for connecting multiple meters, such as Figure 7BAs shown, it is a structural diagram of the device, and the device includes: a generation module 721, which is used to generate a first detection execution plan according to a multi-table connection query request; an input module 722, which is used to input a first detection feature corresponding to the first detection execution plan to a trained target network model, and the target network model obtains a second detection feature according to the first detection feature; the generation module 721 is also used to generate a second detection execution plan based on the second detection feature; wherein the connection order in the second detection execution plan is different from or the same as the connection order in the first detection execution plan; and a processing module 723 is used to perform multi-table connection query processing based on the second detection execution plan.
[0204] The generating module 721 is further configured to generate the first detection feature based on the first detection execution plan; wherein the first detection feature includes an information feature and / or a structural feature;
[0205] The first detection execution plan includes multiple operation nodes, the information feature is used to represent the node information of a single operation node, and the structural feature is used to represent the relationship information between the operation nodes.
[0206] The embodiment of the present application further provides a multi-meter connection processing device, the multi-meter connection processing device comprising: a processor and a machine-readable storage medium, the machine-readable storage medium storing a plurality of computer instructions, the processor performing the following processing when executing the computer instructions:
[0207] Generate a first sample execution plan according to a sample multi-table join query request;
[0208] Inputting a first sample feature corresponding to the first sample execution plan into an initial network model, and obtaining a second sample feature by the initial network model according to the first sample feature;
[0209] generating a second sample execution plan based on the second sample feature; wherein a connection order in the second sample execution plan is different from a connection order in the first sample execution plan;
[0210] The initial network model is trained based on the performance of the first sample execution plan and the performance of the second sample execution plan to obtain a trained target network model.
[0211] The embodiment of the present application also provides another multi-meter connection processing device, the multi-meter connection processing device includes: a processor and a machine-readable storage medium, the machine-readable storage medium stores a number of computer instructions, and the processor performs the following processing when executing the computer instructions:
[0212] Generate a first detection execution plan according to a detection multi-table connection query request;
[0213] Inputting a first detection feature corresponding to the first detection execution plan into a trained target network model, and obtaining a second detection feature by the target network model according to the first detection feature;
[0214] Generate a second detection execution plan based on the second detection feature; wherein the connection order in the second detection execution plan is different from or the same as the connection order in the first detection execution plan;
[0215] Multi-table join query processing is performed based on the second detection execution plan.
[0216] The present application also provides a machine-readable storage medium, on which a number of computer instructions are stored; when the computer instructions are executed, the following processing is performed:
[0217] Generate a first sample execution plan according to a sample multi-table join query request;
[0218] Inputting a first sample feature corresponding to the first sample execution plan into an initial network model, and obtaining a second sample feature by the initial network model according to the first sample feature;
[0219] generating a second sample execution plan based on the second sample feature; wherein a connection order in the second sample execution plan is different from a connection order in the first sample execution plan;
[0220] The initial network model is trained based on the performance of the first sample execution plan and the performance of the second sample execution plan to obtain a trained target network model.
[0221] The present application also provides a machine-readable storage medium, on which a number of computer instructions are stored; when the computer instructions are executed, the following processing is performed:
[0222] Generate a first detection execution plan according to a detection multi-table connection query request;
[0223] Inputting a first detection feature corresponding to the first detection execution plan into a trained target network model, and obtaining a second detection feature by the target network model according to the first detection feature;
[0224] Generate a second detection execution plan based on the second detection feature; wherein the connection order in the second detection execution plan is different from or the same as the connection order in the first detection execution plan;
[0225] Multi-table join query processing is performed based on the second detection execution plan.
[0226] See also Figure 8 As shown, it is a structural diagram of a multi-table connected processing device proposed in an embodiment of the present application, and the multi-table connected processing device includes: a processor 81, a network interface 82, a bus 83, and a memory 84. The memory 84 can be any electronic, magnetic, optical or other physical storage device, which can contain or store information, such as executable instructions, data, etc. For example, the memory 84 can be: RAM (Radom Access Memory, random access memory), volatile memory, non-volatile memory, flash memory, storage drive (such as hard disk drive), solid state hard disk, any type of storage disk (such as optical disk, DVD, etc.).
[0227] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which may be in the form of a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver, a game console, a tablet computer, a wearable device or a combination of any of these devices.
[0228] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing the present application, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0229] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the embodiments of the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0230] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0231] Moreover, these computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0232] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0233] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A method for processing multi-table connections, the method comprising: Generate a first sample execution plan according to a sample multi-table join query request; Inputting a first sample feature corresponding to the first sample execution plan into an initial network model, and obtaining a second sample feature by the initial network model according to the first sample feature; generating a second sample execution plan based on the second sample feature; wherein a connection order in the second sample execution plan is different from a connection order in the first sample execution plan; Training the initial network model based on the performance of the first sample execution plan and the performance of the second sample execution plan to obtain a trained target network model; The training process of the target network model includes: determining whether the current initial network model has converged; if not, adjusting the network parameters of the initial network model based on the performance of the first sample execution plan and the performance of the second sample execution plan to obtain an adjusted initial network model; based on the adjusted initial network model, returning to execute the operation of inputting the first sample feature corresponding to the first sample execution plan into the initial network model; wherein the performance of the second sample execution plan is an estimated performance, or a performance collected when executing the second sample execution plan; If yes, the current initial network model is determined as the trained target network model.
2. According to the method of claim 1, before inputting the first sample feature corresponding to the first sample execution plan into the initial network model, the method further comprises: generating the first sample feature based on the first sample execution plan; Wherein, the first sample feature includes information feature and / or structural feature; The first sample execution plan includes multiple operation nodes, the information feature is used to represent the node information of a single operation node, and the structural feature is used to represent the relationship information between the operation nodes.
3. The method according to claim 2, wherein the information feature comprises at least one of the following vectors: table vector; the first sample execution plan includes a data table identifier, and the position corresponding to the data table identifier in the table vector is a first value; wherein the There are N positions in the table vector, where N is the total number of data tables in the database, and the N positions of the table vector correspond one-to-one to the N data tables; A column vector; the first sample execution plan includes a column identifier, and the position corresponding to the column identifier in the column vector is a first value; wherein the column vector has M positions, M is the total number of columns of each data table in the database, and the M positions of the column vector correspond to the M columns one by one; An operation type vector of an operation node; the operation type vector has P operation type positions and Q operation object positions, P is the total number of operation types, the P operation type positions correspond one-to-one to the P operation types, Q is the total number of operation objects, the Q operation object positions correspond one-to-one to the Q operation objects; the position of the P operation type positions corresponding to the operation type of the operation node is a first value, and the position of the Q operation object positions corresponding to the operation object of the operation node is a first value.
4. The method according to claim 2, wherein each operation node in the first sample execution plan has a unique node identifier, and the structural feature includes a relationship vector of each operation node; The relationship vector of the operation node includes the node identifier of the operation node, the node identifier of the parent node of the operation node, and the node identifier of the child node of the operation node.
5. The method according to claim 1, After the initial network model is trained based on the performance of the first sample execution plan and the performance of the second sample execution plan to obtain a trained target network model, the method further includes: Obtaining a query request for detecting a multi-table connection, generating a first detection execution plan according to the query request for detecting a multi-table connection, and generating a first detection feature based on the first detection execution plan; Inputting the first detection feature into the target network model, and obtaining a second detection feature by the target network model according to the first detection feature; Generate a second detection execution plan based on the second detection feature; wherein the connection order in the second detection execution plan is different from or the same as the connection order in the first detection execution plan; Multi-table join query processing is performed based on the second detection execution plan.
6. The method according to claim 5, The first detection feature includes an information feature and / or a structural feature; The first detection execution plan includes multiple operation nodes, the information feature is used to represent the node information of a single operation node, and the structural feature is used to represent the relationship information between the operation nodes.
7. A method for processing multi-table connections, the method comprising: Generate a first detection execution plan according to a detection multi-table connection query request; Input the first detection feature corresponding to the first detection execution plan to the trained target network model, and the target network model obtains the second detection feature according to the first detection feature; wherein the training process of the target network model includes: determining whether the current initial network model has converged; if so, determining the current initial network model as the trained target network model; if not, adjusting the network parameters of the initial network model based on the performance of the first sample execution plan and the performance of the second sample execution plan to obtain the adjusted initial network model; based on the adjusted initial network model, input the first sample feature corresponding to the first sample execution plan to the initial network model, and the initial network model obtains the second sample feature according to the first sample feature; generate the second sample execution plan based on the second sample feature, and return to perform the operation of determining whether the current initial network model has converged; wherein the performance of the second sample execution plan is the estimated performance, or the performance collected when executing the second sample execution plan; Generate a second detection execution plan based on the second detection feature; wherein the connection order in the second detection execution plan is different from or the same as the connection order in the first detection execution plan; Multi-table join query processing is performed based on the second detection execution plan.
8. The method according to claim 7, before inputting the first detection feature corresponding to the first detection execution plan into the trained target network model, the method further comprises: generating the first detection feature based on the first detection execution plan; Wherein, the first detection feature includes information feature and / or structural feature; The first detection execution plan includes multiple operation nodes, the information feature is used to represent the node information of a single operation node, and the structural feature is used to represent the relationship information between the operation nodes.
9. The method according to claim 8, wherein the information feature comprises at least one of the following vectors: table vector; the first detection execution plan includes a data table identifier, and the position corresponding to the data table identifier in the table vector is a first value; wherein the There are N positions in the table vector, where N is the total number of data tables in the database, and the N positions of the table vector correspond one-to-one to the N data tables; A column vector; the first detection execution plan includes a column identifier, and the position corresponding to the column identifier in the column vector is a first value; wherein the column vector has M positions, M is the total number of columns of each data table in the database, and the M positions of the column vector correspond one-to-one to the M columns; An operation type vector of an operation node; the operation type vector has P operation type positions and Q operation object positions, P is the total number of operation types, the P operation type positions correspond one-to-one to the P operation types, Q is the total number of operation objects, the Q operation object positions correspond one-to-one to the Q operation objects; the position of the P operation type positions corresponding to the operation type of the operation node is a first value, and the position of the Q operation object positions corresponding to the operation object of the operation node is a first value.
10. The method according to claim 8, wherein each operation node in the first detection execution plan has a unique node identifier, and the structural feature includes a relationship vector of each operation node; The relationship vector of the operation node includes the node identifier of the operation node, the node identifier of the parent node of the operation node, and the node identifier of the child node of the operation node.
11. A processing device for multi-meter connection, the device comprising: A generation module, used to generate a first sample execution plan according to a sample multi-table connection query request; An input module, used for inputting a first sample feature corresponding to the first sample execution plan into an initial network model, so that the initial network model obtains a second sample feature according to the first sample feature; The generating module is further used to generate a second sample execution plan based on the second sample feature; the connection order in the second sample execution plan is different from the connection order in the first sample execution plan; A training module, configured to train the initial network model based on the performance of the first sample execution plan and the performance of the second sample execution plan to obtain a trained target network model; The process of training the target network model by the training module includes: determining whether the current initial network model has converged; if not, adjusting the network parameters of the initial network model based on the performance of the first sample execution plan and the performance of the second sample execution plan to obtain an adjusted initial network model; based on the adjusted initial network model, returning to execute the operation of inputting the first sample feature corresponding to the first sample execution plan into the initial network model; wherein the performance of the second sample execution plan is an estimated performance, or a performance collected when executing the second sample execution plan; If yes, the current initial network model is determined as the trained target network model.
12. A processing device for multiple table connections, the device comprising: A generating module, used for generating a first detection execution plan according to a detection multi-table connection query request; An input module, used for inputting the first detection feature corresponding to the first detection execution plan into the trained target network model, and the target network model obtains the second detection feature according to the first detection feature; wherein the training process of the target network model includes: determining whether the current initial network model has converged; if so, determining the current initial network model as the trained target network model; if not, adjusting the network parameters of the initial network model based on the performance of the first sample execution plan and the performance of the second sample execution plan to obtain the adjusted initial network model; based on the adjusted initial network model, inputting the first sample feature corresponding to the first sample execution plan into the initial network model, and the initial network model obtains the second sample feature according to the first sample feature; generating the second sample execution plan based on the second sample feature, and returning to perform the operation of determining whether the current initial network model has converged; wherein the performance of the second sample execution plan is an estimated performance, or a performance collected when executing the second sample execution plan; The generating module is further configured to generate a second detection execution plan based on the second detection feature; wherein the connection order in the second detection execution plan is different from or the same as the connection order in the first detection execution plan; A processing module is used to perform multi-table join query processing based on the second detection execution plan.
13. A processing device for connecting multiple meters, comprising: A processor and a machine-readable storage medium, wherein the machine-readable storage medium stores a plurality of computer instructions, and when the processor executes the computer instructions, the processor performs the following processing: Generate a first sample execution plan according to a sample multi-table join query request; Inputting a first sample feature corresponding to the first sample execution plan into an initial network model, and obtaining a second sample feature by the initial network model according to the first sample feature; generating a second sample execution plan based on the second sample feature; wherein a connection order in the second sample execution plan is different from a connection order in the first sample execution plan; Training the initial network model based on the performance of the first sample execution plan and the performance of the second sample execution plan to obtain a trained target network model; The training process of the target network model includes: determining whether the current initial network model has converged; if not, adjusting the network parameters of the initial network model based on the performance of the first sample execution plan and the performance of the second sample execution plan to obtain an adjusted initial network model; based on the adjusted initial network model, returning to execute the operation of inputting the first sample feature corresponding to the first sample execution plan into the initial network model; wherein the performance of the second sample execution plan is an estimated performance, or a performance collected when executing the second sample execution plan; If yes, the current initial network model is determined as the trained target network model.
14. A processing device for connecting multiple meters, comprising: A processor and a machine-readable storage medium, wherein the machine-readable storage medium stores a plurality of computer instructions, and when the processor executes the computer instructions, the processor performs the following processing: Generate a first detection execution plan according to a detection multi-table connection query request; Input the first detection feature corresponding to the first detection execution plan to the trained target network model, and the target network model obtains the second detection feature according to the first detection feature; wherein the training process of the target network model includes: determining whether the current initial network model has converged; if so, determining the current initial network model as the trained target network model; if not, adjusting the network parameters of the initial network model based on the performance of the first sample execution plan and the performance of the second sample execution plan to obtain the adjusted initial network model; based on the adjusted initial network model, input the first sample feature corresponding to the first sample execution plan to the initial network model, and the initial network model obtains the second sample feature according to the first sample feature; generate the second sample execution plan based on the second sample feature, and return to perform the operation of determining whether the current initial network model has converged; wherein the performance of the second sample execution plan is the estimated performance, or the performance collected when executing the second sample execution plan; Generate a second detection execution plan based on the second detection feature; wherein the connection order in the second detection execution plan is different from or the same as the connection order in the first detection execution plan; Multi-table join query processing is performed based on the second detection execution plan.
15. A machine-readable storage medium having a plurality of computer instructions stored thereon; when the computer instructions are executed, the following processing is performed: Generate a first sample execution plan according to a sample multi-table join query request; Inputting a first sample feature corresponding to the first sample execution plan into an initial network model, and obtaining a second sample feature by the initial network model according to the first sample feature; Generate a second sample execution plan based on the second sample feature; wherein, The connection order in the second sample execution plan is different from the connection order in the first sample execution plan; Training the initial network model based on the performance of the first sample execution plan and the performance of the second sample execution plan to obtain a trained target network model; The training process of the target network model includes: determining whether the current initial network model has converged; if not, adjusting the network parameters of the initial network model based on the performance of the first sample execution plan and the performance of the second sample execution plan to obtain an adjusted initial network model; based on the adjusted initial network model, returning to execute the operation of inputting the first sample feature corresponding to the first sample execution plan into the initial network model; wherein the performance of the second sample execution plan is an estimated performance, or a performance collected when executing the second sample execution plan; If yes, the current initial network model is determined as the trained target network model.
16. A machine-readable storage medium, wherein a plurality of computer instructions are stored on the machine-readable storage medium; when the computer instructions are executed, the following processing is performed: Generate a first detection execution plan according to a detection multi-table connection query request; The first detection feature corresponding to the first detection execution plan is input into the trained target network model, and the target network model obtains the second detection feature according to the first detection feature; wherein, The training process of the target network model includes: determining whether the current initial network model has converged; if so, determining the current initial network model as the trained target network model; if not, adjusting the network parameters of the initial network model based on the performance of the first sample execution plan and the performance of the second sample execution plan to obtain an adjusted initial network model; based on the adjusted initial network model, inputting the first sample feature corresponding to the first sample execution plan into the initial network model, and obtaining the second sample feature from the initial network model according to the first sample feature; generating a second sample execution plan based on the second sample feature, and returning to perform an operation of determining whether the current initial network model has converged; wherein the performance of the second sample execution plan is an estimated performance, or a performance collected when executing the second sample execution plan; Generate a second detection execution plan based on the second detection feature; wherein the connection order in the second detection execution plan is different from or the same as the connection order in the first detection execution plan; Multi-table join query processing is performed based on the second detection execution plan.
Citation Information
Patent Citations
Rule-driven and data-driven combined cross-platform SQL query optimization method
CN111444220A