Training method of neural network model, data processing method and equipment

CN122152847APending Publication Date: 2026-06-05NANJING GLORY SOFTWARE TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
NANJING GLORY SOFTWARE TECH CO LTD
Filing Date
2026-01-29
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

In existing technologies, the analysis and optimization of performance issues in database systems when executing code statements rely on the personal experience of DBAs or SEs, lacking automation capabilities, and are time-consuming and inefficient.

Method used

By training a neural network model, using decision trees and knowledge information to analyze and optimize code statements, generating optimization strategies and adjusting model parameters, a second neural network model is obtained.

Benefits of technology

It enables automated analysis and optimization of code statements, improving analysis accuracy and generalization ability while reducing computational resource consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122152847A_ABST
    Figure CN122152847A_ABST
Patent Text Reader

Abstract

The application relates to the technical field of artificial intelligence, and discloses a neural network model training method, a data processing method and equipment. The method comprises the following steps: an electronic device first acquires a first code statement to be processed and first database information corresponding to the first code statement. Then, the first code statement and the first database information are processed by a decision tree to generate problems existing in the first code statement and an optimization strategy applicable to the first code statement, so as to determine training data based on the first code statement, the first database information, the problems existing in the first code statement and the optimization strategy applicable to the first code statement. Finally, the first neural network model is trained by using the training data to obtain a second neural network model after training. In this way, the second neural network model can be trained. Furthermore, the electronic device can automatically analyze and optimize problems existing in a code statement by using the second neural network model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and in particular to a method for training a neural network model, a data processing method, and an apparatus. Background Technology

[0002] Currently, database systems (such as relational database systems) are a core component of various information technology (IT) management projects. The execution performance of various code statements in the database system (such as structured query language (SQL) statements) also directly affects the responsiveness and business availability of IT management projects.

[0003] Currently, when performance issues arise when executing code statements in a database system, database administrators (DBAs) or system engineers (SEs) need to repeatedly observe system data and manually collect information such as slow logs, execution plans, or electronic device loads. They then analyze and optimize the problem based on their personal experience to fix it.

[0004] However, the above methods of analyzing and fixing problems rely heavily on the individual skills of DBAs or SEs, lack the automation capabilities of electronic devices, and require a significant amount of time from DBAs or SEs. Summary of the Invention

[0005] To address the aforementioned issues, this application provides a method for training a neural network model, a data processing method, and an apparatus to automate the analysis and optimization of problematic code statements.

[0006] In a first aspect, this application provides a method for training a neural network model, applied to an electronic device. The method includes: acquiring a first code statement to be processed and first database information corresponding to the first code statement; processing the first code statement and the first database information using a decision tree to generate problems existing in the first code statement and applicable optimization strategies; determining training data based on first information, wherein the first information includes the first code statement, the first database information, the problems existing in the first code statement, and the applicable optimization strategies; and training a first neural network model using the training data to obtain a trained second neural network model. Specifically, during the training of the first neural network model using the training data, the first problem existing in the first code statement applied to the first database information and the applicable first optimization strategy are inferred from first knowledge information stored in the first neural network model for analyzing and optimizing problems existing in the code statement. Based on the inferred first problem and first optimization strategy, and the problems and optimization strategies in the training data, the parameters of the first neural network model are adjusted to obtain the trained second neural network model. The parameters of the first neural network model include first knowledge information, and the second neural network model stores second knowledge information for analyzing and optimizing problems in the code statements. The second knowledge information is obtained by adjusting the first knowledge information in the parameters of the first neural network model.

[0007] In this way, the electronic device can quickly analyze a large number of first code statements to be optimized through decision trees, generating a large amount of training data to fully train the first neural network model. Then, after training the second neural network model, the electronic device can automatically analyze and optimize the problems (such as SQL problems) in the code statements using the second neural network model. Furthermore, since the neural network model also possesses a certain degree of generalization and reasoning ability, the electronic device can analyze new or complex code problems based on the second neural network model and determine the appropriate optimization strategies for these problems. In addition, in this embodiment, the first neural network model stores first knowledge information for analyzing and optimizing code statements, and during the training process of the first neural network model, the first knowledge information is further adjusted to obtain second knowledge information in the second neural network model that enables more accurate analysis and optimization of code statements. Therefore, in this application, the reasoning results obtained by the electronic device when reasoning about code statements based on the second neural network model are more accurate. Furthermore, the second neural network model used in this application can be any small-scale neural network model with reasoning capabilities, thereby saving the computing and storage resources of the electronic device.

[0008] In one possible implementation of the first aspect above, the above-mentioned processing of the first code statement and the first database information by a decision tree to generate the problems existing in the first code statement and the applicable optimization strategies includes: the decision tree analyzing the first code statement and the first database information based on one or more pre-stored problem types to determine that the problems existing in the first code statement belong to a first problem type; and the decision tree determining the applicable optimization strategy for the first code statement based on the optimization strategies corresponding to each pre-stored problem type, wherein the optimization strategy corresponding to each problem type includes the optimization strategy corresponding to the first problem type.

[0009] In this way, electronic devices can quickly analyze a large number of first code statements to be optimized through decision trees, so as to identify the problems of each code statement and the applicable optimization strategies. This allows electronic devices to quickly obtain and generate a large amount of training data to fully train the first neural network model, resulting in a higher inference accuracy of the trained second neural network model.

[0010] In one possible implementation of the first aspect described above, the method further includes: adjusting the first code statement by the decision tree based on an optimization strategy applicable to the first code statement to obtain an optimized second code statement; and the first information also includes the second code statement.

[0011] In one possible implementation of the first aspect described above, the method further includes: determining, by the decision tree, the strategy advantage corresponding to the optimization strategy applicable to the first code statement, wherein the first information further includes the strategy advantage. And / or, determining, by the decision tree, the adjustment portion of the optimized second code statement relative to the first code statement, wherein the first information further includes the adjustment portion of the second code statement relative to the first code statement, wherein the optimized second code statement is obtained by adjusting the first code statement based on the optimization strategy applicable to the first code statement by the decision tree.

[0012] In this way, the electronic device can obtain more analysis and optimization information corresponding to the first code statement by running the decision tree, making the training data formed based on the optimization information more sufficient and comprehensive. As a result, the reasoning analysis and output results of the second neural network model obtained by the electronic device based on the training data are also more comprehensive.

[0013] In one possible implementation of the first aspect described above, the decision tree includes an input layer, a problem identification layer, an optimization strategy selection layer, and an execution layer. The above-described processing of the first code statement and first database information using the decision tree to generate the problem existing in the first code statement and the applicable optimization strategy includes: the input layer receiving the first code statement and the first database information as input data for the decision tree; the problem identification layer analyzing the first code statement and the first database information from the input layer based on one or more pre-stored problem types to determine that the problem existing in the first code statement belongs to a first problem type; the optimization strategy selection layer determining the applicable optimization strategy for the first code statement based on the pre-stored optimization strategies corresponding to each problem type and the first problem type existing in the first code statement from the problem identification layer, wherein the optimization strategy corresponding to each problem type includes the optimization strategy corresponding to the first problem type; and the execution layer outputting the problem existing in the first code statement and the applicable optimization strategy according to the first problem type existing in the first code statement and the applicable optimization strategy from the optimization strategy selection layer, as the output data of the decision tree.

[0014] Thus, based on the decision tree structure described above, a large number of first code statements to be optimized can be quickly analyzed to identify the problems in each code statement and the applicable optimization strategies. This allows electronic devices to quickly acquire and generate a large amount of training data to fully train the first neural network model, resulting in a higher inference accuracy for the trained second neural network model.

[0015] In one possible implementation of the first aspect described above, the method further includes: adjusting the first code statement by the execution layer based on an optimization strategy applicable to the first code statement to obtain an optimized second code statement, wherein the first information further includes the second code statement. And / or, determining the strategy advantage corresponding to the optimization strategy applicable to the first code statement by the execution layer, wherein the first information further includes the strategy advantage. And / or, determining the adjustment portion of the optimized second code statement relative to the first code statement by the execution layer, wherein the first information further includes the adjustment portion, wherein the optimized second code statement is obtained by adjusting the first code statement by the execution layer based on the optimization strategy applicable to the first code statement.

[0016] In one possible implementation of the first aspect above, the first neural network model includes a first network layer, which stores first knowledge information. The first network layer is capable of inferring, based on the first knowledge information, a first problem existing in a first code statement applied to first database information and a first optimization strategy applicable thereto.

[0017] Furthermore, in the process of training the first neural network model using training data, the first problem and the applicable first optimization strategy for the first code statement applied to the first database information are inferred from the first knowledge information stored in the first neural network model for analyzing and optimizing the problems existing in the code statement. Based on the inferred first problem and the first optimization strategy, as well as the problems and optimization strategies in the training data, the parameters of the first neural network model are adjusted to obtain the trained second neural network model. This includes: in the process of training the first neural network model using training data, the first problem and the applicable first optimization strategy for the first code statement are inferred from the first knowledge information stored in the first network layer of the first neural network model. Based on the inferred first problem and the first optimization strategy, as well as the problems and optimization strategies in the training data, the parameters of the first network layer in the first neural network model are adjusted to obtain the second network layer, and a second neural network model with the second network layer is obtained. The second network layer stores second knowledge information, and the second network layer can be used to determine the problems existing in the code statement to be processed and the applicable optimization strategies based on the second knowledge information.

[0018] In one possible implementation of the first aspect above, during the process of training the first neural network model using training data, the first problem existing in the first code statement and the applicable first optimization strategy are inferred from the first knowledge information stored in the first network layer of the first neural network model. Based on the inferred first problem and first optimization strategy, and the problems and optimization strategies in the training data, the parameters of the first network layer in the first neural network model are adjusted to obtain a second network layer, resulting in a second neural network model with the second network layer. This includes: concatenating various data in the training data into a structured target data sequence through the first network layer; and concatenating the first code statement and the first database information in the training data through the first network layer. The table structure and / or index information in the first database information are concatenated into a structured training data sequence; the training data sequence is inferred by the first network layer based on the first knowledge information to obtain the inference result sequence corresponding to the training data sequence; wherein, the inference result sequence includes at least the first code statement, the table structure and / or index information in the first database information, the first problem existing in the inferred first code statement, and the first optimization strategy applicable to the inferred first code statement; based on the target data sequence and the corresponding inference result sequence, the loss function result of the first network layer is determined; based on the loss function result and the backpropagation mechanism, the parameters in the first network layer are adjusted to obtain the second network layer, and a second neural network model with the second network layer is obtained.

[0019] Thus, by using the above method, the first network layer storing the first knowledge information in the first neural network model can be trained to obtain the second network layer, thereby obtaining a second neural network model with the second network layer, which enables the second neural network model to automatically analyze and optimize the problems existing in the code statement (such as SQL problems).

[0020] In one possible implementation of the first aspect above, the above-mentioned reasoning of the training data sequence by the first network layer based on the first knowledge information to obtain the reasoning result sequence corresponding to the training data sequence includes: encoding the training data sequence to obtain an encoded sequence; calculating the FFN result corresponding to the encoded sequence based on the feed forward network (FFN) function; calculating the gating signal corresponding to the encoded sequence based on the gating function, and when the gating signal indicates that the first neural network model is reasoning on the code statement to be processed, determining the patch result corresponding to the encoded sequence based on the patch function and the first knowledge information; and determining the reasoning result sequence of the first network layer for the encoded sequence based on the FFN result and the patch result corresponding to the encoded sequence.

[0021] In one possible implementation of the first aspect above, determining the loss function result of the first network layer based on the target data sequence and the corresponding inference result sequence includes: determining the first loss result of the first network layer based on the target data sequence; determining the second loss result of the first network layer based on the FFN result and the inference result sequence; and determining the loss function result of the first network layer based on the first loss result and the second loss result.

[0022] In one possible implementation of the first aspect above, the first neural network model includes n Transformer layers, the second neural network model includes n Transformer layers, the first network layer is the last Transformer layer among the n Transformer layers of the first neural network model, and the second network layer is the last Transformer layer among the n Transformer layers of the first neural network model, where n is an integer greater than 1.

[0023] In this way, by storing the first or second knowledge information in the last Transformer layer, the other structures of the Transformer neural network can remain unchanged, thereby enabling the second neural network model to maintain the reasoning and generalization capabilities of the original Transformer neural network.

[0024] In one possible implementation of the first aspect above, the second network layer is further configured to optimize the code statement to be processed according to the optimization strategy corresponding to the code statement to be processed to obtain the optimized target code statement; and / or, the second network layer is further configured to determine the strategy advantage corresponding to the optimization strategy applicable to the code statement to be processed.

[0025] Secondly, this application provides a data processing method applied to an electronic device. The method includes: acquiring a third code statement to be processed and the second database information corresponding to the third code statement; inputting the third code statement and the second database information into a second neural network model; and analyzing the third code statement and the second database information based on second knowledge information by running the second neural network model to determine the problems existing in the third code statement and the optimization strategy applicable to the third code statement.

[0026] The second neural network model is obtained by training the first neural network model with training data. The training data is determined based on the first information, which includes the first code statement to be processed, the first database information corresponding to the first code statement, and the problems existing in the first code statement and the optimization strategy applicable to the first code statement determined based on the decision tree.

[0027] In the process of training the first neural network model using training data, the first neural network model can infer, based on stored first knowledge information used to analyze and optimize problems in code statements, the first problem existing in the first code statement applied to the first database information and the applicable first optimization strategy. Furthermore, the inferred first problem and first optimization strategy, as well as the problems and optimization strategies in the training data, can be used to adjust the parameters of the first neural network model to obtain the trained second neural network model. The parameters of the first neural network model include the first knowledge information, and the second neural network model stores second knowledge information used to analyze and optimize problems in code statements; the second knowledge information is obtained by adjusting the first knowledge information in the parameters of the first neural network model.

[0028] Thus, through the above method, electronic devices can automatically analyze and optimize problems in code statements (such as SQL problems) using a second neural network model. Furthermore, since the neural network model also possesses a certain degree of generalization and reasoning ability, the electronic device can analyze novel and complex code problems based on the second neural network model and determine the appropriate optimization strategies for these problems. Additionally, because the second neural network model mentioned in this application contains second knowledge information specifically for analyzing and optimizing code statements, and this second knowledge information is obtained by further adjusting the first knowledge information specifically for analyzing and optimizing code statements during the training of the first neural network model, the second neural network model can perform more accurate analysis and optimization of code statements using this second knowledge information. This results in more accurate reasoning results when the electronic device reasons about code statements based on the second neural network model. Moreover, the second neural network model used in this application can be any small-scale neural network model with reasoning capabilities, thereby saving computational and storage resources for the electronic device.

[0029] In one possible implementation of the second aspect above, the method further includes: adjusting the third code statement based on the optimization strategy applicable to the third code statement using a second neural network model to obtain an optimized fourth code statement.

[0030] In one possible implementation of the second aspect described above, the second neural network model includes a first input layer, n Transformer layers, and a first output layer, where n is an integer greater than 1.

[0031] The first input layer receives the third code statement to be processed and the corresponding second database information. The second neural network model includes a second network layer, which is the last Transformer layer among n Transformer layers. This second network layer stores second knowledge information for analyzing and optimizing the code statement, and is used to determine the problems and applicable optimization strategies for the third code statement to be processed based on this second knowledge information. The first output layer outputs the problems and applicable optimization strategies for the third code statement to be processed.

[0032] In this way, by storing the second knowledge information in the last Transformer layer, the structure of other Transformer layers can remain unchanged, thereby enabling the second neural network model to maintain the reasoning and generalization capabilities of the original Transformer neural network.

[0033] In one possible implementation of the second aspect above, the method further includes: optimizing the third code statement according to the optimization strategy corresponding to the third code statement through the second network layer to obtain an optimized fourth code statement, and outputting the optimized fourth code statement through the first output layer; and / or determining the strategy advantage corresponding to the optimization strategy applicable to the third code statement through the second network layer, and outputting the strategy advantage corresponding to the optimization strategy applicable to the third code statement through the first output layer.

[0034] In one possible implementation of the second aspect above, obtaining the third code statement to be processed and the second database information corresponding to the third code statement includes: querying the third code statement from the slow log of the database system, and obtaining the second database information corresponding to the third code statement from the database system.

[0035] Thirdly, this application also provides an electronic device, comprising: at least one memory and at least one processor, wherein the memory is coupled to the processor; the memory is used to store computer program code / instructions; when the computer program code / instructions are executed by the processor, the electronic device causes the electronic device to perform the training method of the neural network model mentioned in the first aspect and any possible implementation of the first aspect, or to perform the data processing method mentioned in the second aspect and any possible implementation of the second aspect.

[0036] Fourthly, this application also provides a readable storage medium storing instructions that, when executed on an electronic device, cause the electronic device to perform the training method of the neural network model mentioned in the first aspect and any possible implementation thereof, or to perform the data processing method mentioned in the second aspect and any possible implementation thereof.

[0037] Fifthly, this application also provides a computer program product, comprising: computer instructions, which, when executed on an electronic device, cause the electronic device to perform a training method for a neural network model mentioned in the first aspect and any possible implementation thereof, or to perform a data processing method mentioned in the second aspect and any possible implementation thereof.

[0038] In a sixth aspect, this application also provides a chip including a processor, the processor being configured to read and execute computer code / instructions stored in a memory to execute the training method of the neural network model mentioned in the first aspect and any possible implementation of the first aspect, or to execute the data processing method mentioned in the second aspect and any possible implementation of the second aspect.

[0039] The beneficial effects of the fourth to sixth aspects mentioned above can be referred to the relevant descriptions in the first aspect and any possible implementation of the first aspect, or to the second aspect and any possible implementation of the second aspect, which will not be repeated here. Attached Figure Description

[0040] Figure 1 According to some embodiments, a flowchart illustrating an electronic device for automating the analysis and optimization of SQL problems is shown;

[0041] Figure 2 According to some embodiments, a flowchart illustrating another electronic device for automating the analysis and optimization of SQL problems is shown;

[0042] Figure 3A According to some embodiments of this application, a flowchart illustrating a training method for a first neural network model is shown;

[0043] Figure 3B According to some embodiments of this application, a flowchart illustrating the training of a first neural network model to obtain a second neural network model is shown.

[0044] Figure 4 According to some embodiments of this application, a schematic diagram of the structure of a first neural network model is shown;

[0045] Figure 5 According to some embodiments of this application, a flowchart illustrating a training method for a second neural network model is shown;

[0046] Figure 6 According to some embodiments of this application, a schematic diagram of a first network layer performing inference on training data is shown;

[0047] Figure 7 According to some embodiments of this application, a flowchart of a data processing method is shown;

[0048] Figure 8 According to some embodiments of this application, a schematic diagram of the structure of a second neural network model is shown;

[0049] Figure 9 According to some embodiments of this application, a schematic diagram of an overall process for constructing a decision tree, training a first neural network model, and applying a second neural network model is shown.

[0050] Figure 10 According to some embodiments of this application, a schematic diagram of a decision tree structure is shown;

[0051] Figure 11According to some embodiments of this application, a schematic diagram of the hardware structure of an electronic device is shown. Detailed Implementation

[0052] The illustrative embodiments of this application include, but are not limited to, a method for training a neural network model, a data processing method, and an apparatus.

[0053] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions in the embodiments of this application will be described in detail below with reference to the accompanying drawings and specific implementation methods.

[0054] As described in the background section, when performance issues arise during database system code execution, DBAs or SEs need to repeatedly observe system data and manually collect information such as slow logs, execution plans, or electronic device loads. They then analyze and optimize the problem based on their personal experience to fix it. However, this method of problem analysis and repair heavily relies on the individual skills of the DBA or SE, lacks the automation capabilities of electronic devices, and consumes a significant amount of the DBA's or SE's time.

[0055] Currently, there are several solutions that enable electronic devices to automatically analyze and optimize code statements. These will be discussed in detail below. Figure 1 and Figure 2 As shown, taking SQL statements as an example, this paper provides an exemplary description of a method for automatically analyzing and optimizing problems (or simply SQL problems) that exist in electronic devices using SQL statements.

[0056] The following is a combination of... Figure 1 As shown, an exemplary description is provided of the process of automating the analysis and optimization of SQL issues by invoking a rules system.

[0057] S11: Obtain the SQL statement to be optimized from the slow log of the database system.

[0058] For example, the slow log (also known as the slow query log) is a database system (such as MySQL) TM This is a logging mechanism in the system, primarily used to record information about SQL statements whose execution time exceeds a set time threshold. For example, if the time threshold is set to 5 seconds, the database system can record information about SQL statements whose execution time exceeds 5 seconds in the slow log for subsequent analysis and optimization.

[0059] S12: Obtain the database structure and indexes, as well as SQL execution information such as the execution plan.

[0060] For example, a database structure is the organization and rules of data created within a database system. For instance, a database structure may include, but is not limited to, data types (e.g., a data type can be an integer) and / or constraints (e.g., whether an item can be nullable, etc.).

[0061] For example, database indexes can be used to quickly retrieve data in a database system. When writing SQL statements to be optimized, the index can also be used to query the corresponding data or perform operations on the data.

[0062] For example, an execution plan is a detailed execution scheme generated by a database system for executing a SQL statement. It can be used to show how the database system accesses data, uses indexes, and other information. For example, in MySQL... TM In database systems, you can add the "EXPLAIN" field before an SQL statement to obtain the execution plan of the SQL statement to be optimized, such as the indexes used and the number of table rows scanned.

[0063] For example, the electronic device can also obtain other SQL execution information such as the execution time of the SQL statement to be optimized.

[0064] S13: Obtain hardware utilization information such as central processing unit (CPU) and input / output (IO).

[0065] For example, IO can refer to disk IO involving reading or writing data from a disk or memory cache IO involving reading or writing data from a memory cache.

[0066] S14: Problems encountered when calling the rule system to determine the execution of SQL statements to be optimized.

[0067] For example, developers can pre-configure various SQL problems and corresponding solutions within the rules system. For instance, information such as the database structure, indexes, SQL execution information, and / or hardware utilization information for each SQL problem can be stored. Then, after obtaining the information shown in S12 and S13, the electronic device can determine the corresponding SQL problem within the rules system.

[0068] S15: Output SQL statement optimization solutions.

[0069] For example, when developers pre-set various SQL issues in a rules system, they also set corresponding solutions. Similarly, once an electronic device identifies a specific SQL issue in the rules system, it can also determine the corresponding solution. For instance, if the rules system identifies that the SQL statement to be optimized uses an IN subquery, the corresponding optimization solution can be output as "replace the IN subquery with an EXISTS subquery," thus avoiding the slow execution efficiency caused by the full table scan required by the IN subquery.

[0070] Thus, through the methods described above, electronic devices can automate the analysis and optimization of SQL problems, with clear processing logic and reliable conclusions. However, the above-mentioned scheme, which relies solely on preset rules (such as the corresponding situations and solutions for each SQL problem), suffers from weak generalization ability, resulting in its inability to solve novel or overly complex SQL problems.

[0071] The following is combined with Figure 2 As shown, an exemplary description is provided of the process of automating the analysis and optimization of SQL problems using a large artificial intelligence (AI) model.

[0072] S21: Obtain the SQL statement to be optimized from the slow log of the database system.

[0073] S22: Obtain the database structure and indexes, as well as SQL execution information such as the execution plan.

[0074] S23: Obtain hardware utilization information such as CPU and I / O.

[0075] For details regarding S21 to S23 above, please refer to... Figure 1 The details described in S11 to S13 are not repeated here.

[0076] S24: Construct relevant information such as prompt words and knowledge graphs, and submit the relevant information as context to the AI ​​big model.

[0077] For example, a large AI model could refer to DeepSeek. TM Models of equal size.

[0078] For example, a knowledge graph can refer to the user's experience or knowledge about the analysis and optimization of SQL problems, which is input into the AI ​​model. Hint words can refer to the database information corresponding to the SQL statement to be optimized obtained in S22 and S23 above, which can be input into the AI ​​model.

[0079] For example, large AI models (such as DeepSeek) TMIt can learn from the content in the knowledge graph input by the user, and then analyze the actual database business.

[0080] S25: Use AI large-scale models to identify problems when executing SQL statements that need optimization.

[0081] For example, after the AI ​​big model learns the content in the knowledge graph mentioned in S24, it can analyze the problems existing in the SQL statement to be optimized based on the learned problem analysis experience and actual database business (such as hint words based on the database information corresponding to the SQL statement to be optimized).

[0082] S26: Output SQL statement optimization solutions.

[0083] For example, after the AI ​​model analyzes the SQL problem, the AI ​​can also optimize the SQL statement based on the optimization experience it has learned to solve the SQL problem.

[0084] Thus, through the methods described above, electronic devices can automate the analysis and optimization of SQL problems. Furthermore, large AI models can possess a certain degree of generalization and reasoning ability, enabling them to handle novel SQL problems. However, the above methods suffer from the illusion problem, meaning the reliability of the reasoning conclusions cannot be guaranteed. For example, when users use DeepSeek... TM When analyzing and optimizing SQL problems, users input information into DeepSeek. TM The knowledge graphs in DeepSeek often consist of only simple, routine experiences, leading to... TM The lack of learning samples makes DeepSeek... TM When analyzing a company's actual database operations, the reliability of inference conclusions cannot be guaranteed. Furthermore, the large scale of AI models leads to high computational resource consumption by electronic devices when running them.

[0085] In summary, currently, electronic devices cannot simultaneously achieve high accuracy of inference results, strong generalization ability, and low computational resource consumption when performing automated analysis and optimization of SQL problems.

[0086] To address the aforementioned issues, this application provides a data processing method that enables the trained neural network model (as an example of a second neural network model) to automatically analyze and optimize problematic code statements, while simultaneously achieving high accuracy in inference results, strong generalization ability, and low computational resource consumption.

[0087] Specifically, in this embodiment, the electronic device can first obtain a first code statement (such as an SQL statement) to be processed and the first database information corresponding to the first code statement. Then, the electronic device can process the first code statement and the first database information through a decision tree to generate the problems existing in the first code statement and the applicable optimization strategies. Based on the first information, such as the first code statement, the first database information, the problems existing in the first code statement, and the applicable optimization strategies, the electronic device can determine the training data. Finally, the electronic device can train the first neural network model using the training data to obtain the trained second neural network model.

[0088] In the process of training a first neural network model using training data, the electronic device can infer, through the first knowledge information stored in the first neural network model used for analyzing and optimizing problems in code statements, the first problem existing in the first code statement applied to the first database information and the applicable first optimization strategy. Then, based on the inferred first problem and first optimization strategy, as well as the problems and optimization strategies in the training data, the electronic device can adjust the parameters of the first neural network model (including, for example, the first knowledge information) to obtain a trained second neural network model. Furthermore, the second neural network model also stores second knowledge information used for analyzing and optimizing problems in code statements, wherein the second knowledge information is obtained by adjusting the first knowledge information in the parameters of the first neural network model.

[0089] Thus, a second neural network model can be trained using the above method. Then, upon obtaining the code statement to be processed (as an example of a third code statement) and the corresponding second database information, the electronic device can input the third code statement and the second database information into the second neural network model and run the model to analyze the third code statement and the second database information based on the second knowledge information, thereby identifying the problems existing in the third code statement and the applicable optimization strategies. In other words, the second neural network model trained based on the method provided in this application can be used for automated analysis and optimization of problems existing in code statements (such as SQL problems). Furthermore, since the neural network model also possesses a certain degree of generalization and reasoning ability, the second neural network model mentioned in this application can analyze new or complex code problems and determine the applicable optimization strategies for these new or complex code problems. In addition, compared to... Figure 2The example shown only utilizes widely used AI models for automated code analysis and optimization. In this embodiment, the first neural network model stores first knowledge information for analyzing and optimizing code statements. Furthermore, during the training of the first neural network model, this first knowledge information is further adjusted to obtain second knowledge information in the second neural network model, enabling more precise analysis and optimization of code statements. Therefore, in this application, the reasoning results obtained by the electronic device when reasoning about code statements based on the second neural network model are more accurate. Moreover, compared to… Figure 2 The widely used AI models employed are mostly large-scale multimodal visual-language models (such as DeepSeek). TM (etc.), the second neural network model used in this application can be any small-scale neural network model with reasoning ability, thereby saving computing and storage resources of electronic devices.

[0090] It should be noted that the database system mentioned in this application may refer to MySQL. TM Oracle Database TM Microsoft SQL Server TM Redis TM Or MongoDB TM It can be used to store any type of data, such as image data, audio data, communication data, industrial data, or user data.

[0091] It should be noted that the code statements mentioned in this application can be any code statements such as SQL statements or MangoDB query language (MQL) statements, which can be used to query, modify or delete any type of data such as image data, audio data, communication data, industrial data or user data in the database system.

[0092] It should be noted that, in the embodiments of this application, the electronic device that trains the first neural network model to obtain the second neural network model and the electronic device that runs the second neural network model to analyze and optimize the code statements to be processed can be the same or different electronic devices. For example, developers can train the first neural network model on a first electronic device to obtain the second neural network model. Then, after obtaining the second neural network model, developers can continue to run the second neural network model on the first electronic device to analyze and optimize the code statements to be processed; or, after obtaining the second neural network model, developers can also deploy the second neural network model on any second electronic device (such as a user terminal), so that the second electronic device can analyze and optimize the code statements to be processed by running the second neural network model.

[0093] It should be noted that the electronic devices mentioned in this application may include, but are not limited to, mobile stations (MS) and mobile terminals (MT). For example, electronic devices may be desktop computers, laptops, mobile phones, wearable devices, tablets, virtual reality (VR) devices, augmented reality (AR) devices, terminals in industrial control, terminals in smart grids, terminals in smart cities, terminals in smart homes, etc. This application does not limit the specific form of the electronic devices.

[0094] The following is based on Figure 3A The flowchart shown illustrates the training method for the neural network model mentioned in the embodiments of this application. This neural network model training method can be applied to electronic devices, such as any electronic device like the computer mentioned above. Figure 3A As shown, the specific training method for the neural network model is as follows:

[0095] S301: Obtain the first code statement to be processed and the first database information corresponding to the first code statement.

[0096] In some embodiments, the first code statement may be obtained from the slow log of the database system. The slow log is a database system log (such as MySQL). TMThis is a logging mechanism in the system, primarily used to record information about code statements (such as SQL statements) whose execution time exceeds a set time threshold. For example, if the time threshold is set to 5 seconds, the database system can record information about code statements whose execution time exceeds 5 seconds in the slow log for subsequent analysis and optimization.

[0097] In some embodiments, the first database information may include, but is not limited to, one or more types of information such as database structure (also known as database metadata information), execution plan of the first code statement, and hardware utilization information. For example, database structure refers to the data organization format and rules created within the database system, and may include, but is not limited to, created tables, data types (e.g., data types can be integers), and / or constraints (e.g., whether an item can be nullable, etc.). The execution plan of the first code statement can be a detailed execution scheme generated by the database system to execute the first code statement, which can be used to demonstrate how the database system accesses data, uses indexes, etc. For example, in MySQL... TM In database systems, you can add the "EXPLAIN" field before the first code statement to obtain the execution plan of that statement. Hardware utilization information can include I / O or CPU utilization, etc.

[0098] S302: Process the first code statement and the first database information through a decision tree to generate the problems existing in the first code statement and the applicable optimization strategies.

[0099] In some embodiments, a decision tree is a machine learning algorithm used to solve classification problems. An electronic device can run a decision tree to analyze a first code statement and first database information to determine the problems with the first code statement and the applicable optimization strategies.

[0100] For example, a decision tree can analyze a first code statement and first database information by pre-storing one or more problem types, thereby determining that the problem in the first code statement belongs to the first problem type. For example, the problem types pre-stored in the decision tree (such as storing the terminology and corresponding situations of each problem type in the corresponding field) may include, but are not limited to, one or more of the following: (1) Subquery, which may refer to one or more subquery statements nested inside a query statement, which may lead to repeated execution or multiple full table scans. (2) Multi-table join (JOIN), which may refer to combining two or more tables through the JOIN field, which may result in slow query efficiency due to improper table join order. (3) Aggregation, which may refer to operating on a set of values ​​obtained by querying through fields such as summation (SUM field) and maximum value (MAX field), which may generate large overhead due to sorting and grouping. (4) Deduplication (DISTINCT), which may refer to deleting duplicate results obtained by querying through the DISTINCT field, which may increase overhead due to sorting and deduplication or some deduplication may be unnecessary. (5) Complex expression, which may refer to calculating complex function operations, which may generate large overhead. (6) Window function refers to performing calculations on a "window" of data (i.e., a set of related rows), which may result in a relatively complex execution plan. (7) Index can be used to quickly locate data, but the query efficiency may be slow due to improper index selection or no index. (8) Partition refers to dividing a large table into smaller tables, which may result in a large management overhead due to too many partitions. (9) Materialized view refers to a table that stores query results, which may result in a large overhead due to periodic refresh. (10) Data distribution skew refers to the uneven distribution of data in columns, which may result in a slow query efficiency in some partitions. (11) Executor capability refers to the underlying algorithm used by the database system when executing code, which may result in a slow query efficiency due to the use of an algorithm that is not suitable for the data characteristics. Thus, when one or more of the above problem types are stored in the decision tree, the decision tree can perform matching analysis on the first code statement and the first database information based on the terminology and corresponding situation (such as database structure, execution situation, etc.) of each stored problem type in the corresponding domain, thereby determining that the problem existing in the first code statement belongs to the first problem type.

[0101] Furthermore, after the decision tree determines the first problem type of the first code statement, it can also determine the applicable optimization strategy for the first code statement based on the pre-stored optimization strategies corresponding to each problem type (e.g., including the optimization strategy corresponding to the first problem type). For example, Table 1 shows the strategies stored in the decision tree and the output optimization strategies when the problem of the first code statement belongs to different problem types. Specifically, as shown in Table 1:

[0102] Table 1

[0103]

[0104] As shown in Table 1, the decision tree can store optimization strategies corresponding to various problem types, so that the decision tree can output the optimization strategy applicable to the first code statement based on the optimization strategy for each problem type. Specifically, as described below:

[0105] (1) Subquery problems (also known as subquery rewriting scenarios) can be addressed by replacing the query statement with the "IN" field with the query statement with the "EXIST" field, converting the subquery statement into a flattening operation of an equivalence join, or converting correlated subqueries (i.e., subqueries that reference columns from the outer query) into decorrelated subqueries. For example, if the first problem type is a subquery problem and the first code statement contains an "IN" subquery, the decision tree can output the corresponding optimization strategy as replacing the query statement with the "EXIST" field.

[0106] (2) For multi-table JOIN problems, the corresponding optimization strategies can be to adjust the join order of the tables, eliminate some redundant JOIN operations when the joined tables already contain the required data, or replace the "LEFT JOIN" operation with the "INNER JOIN" operation when all rows in the left table have a match in the right table. For example, if the first problem type is a multi-table JOIN problem, the decision tree can determine that the optimization strategy applicable to the first code statement is to adjust the join order of the tables based on the optimization strategies applicable to multi-table JOIN problems.

[0107] (3) For aggregation problems, the corresponding optimization strategies can be predicate push-up operations (i.e., functions or expressions that return true or false boolean values) that execute predicates as early as possible, semi-aggregation operations that perform partial aggregation locally and then global aggregation in a distributed system, or group pruning operations that remove unnecessary groups based on filtering conditions of the grouping key. For example, if the first problem type is an aggregation problem, the decision tree can determine the optimization strategies applicable to the first code statement as predicate push-up strategy and semi-aggregation strategy based on the optimization strategies applicable to aggregation problems.

[0108] (4) For the deduplication problem, the corresponding optimization strategy can be to convert DISTINCT to GROUP BY when the semantics of DISTINCT are equivalent to those of GROUP BY. For example, if the first problem type is the deduplication problem, the decision tree can determine the optimization strategy applicable to the first code statement as converting DISTINCT to GROUP BY based on the optimization strategy applicable to the deduplication problem.

[0109] (5) For complex expression problems, the corresponding optimization strategies can be constant folding strategies, such as directly calculating the constant part of the expression at compile time (e.g., directly replacing "8" with the constant "3+5" at compile time), pushdown strategies, or derived column caching strategies, which cache the calculation results of repeatedly calculated expressions to avoid repeated calculations. For example, if the first problem type is a complex expression problem, the decision tree can determine the optimization strategies applicable to the first code statement as constant folding strategies and pushdown strategies based on the optimization strategies applicable to complex expression problems.

[0110] (6) For window function problems, the corresponding optimization strategies can be to merge the calculations of multiple window functions with the same window definition, or to use the index to accelerate the calculation of window functions when matching the partition key and index of the window function. For example, if the first problem type is a window function problem, the decision tree can determine that the optimization strategy applicable to the first code statement is the strategy of merging identical windows based on the optimization strategies applicable to window function problems.

[0111] (7) For indexing issues, the corresponding optimization strategy can be a covering index strategy that creates an index containing all fields in the query, or a suitable composite index that is created based on the query conditions, join conditions, and / or sorting conditions. For example, if the first problem type is an indexing problem, the decision tree can determine that the optimization strategy applicable to the first code statement is to create a covering index strategy based on the optimization strategies applicable to indexing problems.

[0112] (8) For partitioning problems, the corresponding optimization strategy can be to check whether the query conditions contain partition keys so that only relevant partitions are scanned to reduce data access volume. For example, if the first problem type is a partitioning problem, the decision tree can determine that the optimization strategy applicable to the first code statement is the partitioning pruning condition checking strategy based on the optimization strategies applicable to partitioning problems.

[0113] (9) Materialized view problem: The corresponding optimization strategy can be to rewrite the query to use an existing materialized view, thereby avoiding repeated calculations, which is the query rewrite matching materialized view (MV) strategy. For example, if the first problem type is a materialized view problem, the decision tree can determine that the optimization strategy applicable to the first code statement is the query rewrite matching MV strategy based on the optimization strategies applicable to materialized view problems.

[0114] (10) For the data skew problem, the corresponding optimization strategies can be the Skew Join strategy, which processes the data of the skew key separately and performs the JOIN operation normally on the other keys, or the Dynamic Bucketing strategy, which dynamically adjusts the bucketing strategy according to the data distribution to make the data distribution more even. For example, if the first problem type is the data skew problem, the decision tree can determine that the optimization strategy applicable to the first code statement is the Skew Join strategy based on the optimization strategy applicable to the data skew problem.

[0115] (11) For the executor capability problem, the corresponding optimization strategy can be to select a suitable JOIN algorithm Hash / Merge Join strategy based on factors such as data size, whether it is sorted, and whether there is an index, or to adjust the parallelism of query execution. For example, if the first problem type is the executor capability problem, the decision tree can determine that the optimization strategy applicable to the first code statement is parallel scheduling optimization based on the optimization strategy applicable to the executor capability problem.

[0116] Thus, when the decision tree stores the optimization strategies applicable to one or more problem types shown in Table 1, the decision tree can perform matching analysis on the first code statement and the first problem type to which the first code statement exists, thereby determining the optimization strategy applicable to the first code statement.

[0117] In summary, through the above methods, electronic devices can analyze the first code statement and the first database information by running a decision tree to determine the problems existing in the first code statement and the applicable optimization strategies.

[0118] It is understood that in this embodiment, the first code statement may contain one or more problem types. For example, the first code statement may contain both subquery problems and complex expression problems. Furthermore, for each problem present in the first code statement, the decision tree can provide a corresponding optimization strategy.

[0119] Furthermore, in some other embodiments, after determining the optimization strategy applicable to the first code statement, the decision tree can also adjust the first code statement according to the optimization strategy applicable to the first code statement to obtain an optimized second code statement. For example, if the optimization strategy applicable to the first code statement is to replace the query statement with the "IN" field with the query statement with the "EXIST" field, then the decision tree can adjust the first code statement based on this optimization strategy to obtain an optimized second code statement.

[0120] And / or, in other embodiments, the decision tree may also determine the adjustments (such as field changes) made to the optimized second code statement relative to the first code statement. The optimized second code statement is obtained by adjusting the first code statement based on the optimization strategy applicable to the first code statement.

[0121] And / or, in other embodiments, the decision tree can also determine the strategy advantage corresponding to the optimization strategy applicable to the first code statement. For example, the strategy advantage of the optimization strategy corresponding to each problem type can be pre-stored in the decision tree. For example, if the optimization strategy applicable to the first code statement is to replace the query statement with the query statement with the "IN" field and pre-store the strategy advantage of reducing full table scans and thus improving performance, then the decision tree can also directly output the strategy advantage.

[0122] Thus, through the above method, the electronic device can obtain more analysis and optimization information corresponding to the first code statement by running the decision tree, making the training data formed based on the optimization information more sufficient and comprehensive, thereby making the training process of the electronic device on the first neural network model based on the training data more thorough.

[0123] S303: Determine training data based on the first information, wherein the first information includes the first code statement, the first database information, the problems existing in the first code statement, and the optimization strategy applicable to the first code statement.

[0124] In some embodiments, if the decision tree can further adjust the first code statement according to the optimization strategy applicable to the first code statement to obtain an optimized second code statement, then the first information may further include the optimized second code statement. And / or, in other embodiments, if the decision tree can further determine the strategy advantage corresponding to the optimization strategy applicable to the first code statement, then the first information may further include the strategy advantage. And / or, in other embodiments, if the decision tree can further determine the adjusted portion of the second code statement obtained by adjusting the first code statement based on the applicable optimization strategy relative to the first code statement, then the first information may further include the adjusted portion of the second code statement relative to the first code statement. This application does not specifically limit the first information.

[0125] Thus, compared to manually collecting training data, this application can quickly generate a large amount of training data based on decision trees to train the first neural network model, making the training samples more sufficient and thus making the training process of the first neural network model more thorough.

[0126] S304: Train the first neural network model using training data to obtain the trained second neural network model.

[0127] Specifically, the process of training the first neural network model using training data can be referred to as follows: Figure 3B As described in S3041 to S3042:

[0128] S3041: By inferring the first problem existing in the first code statement applied to the first database information and the applicable first optimization strategy from the first knowledge information stored in the first neural network model for analyzing and optimizing the problems existing in the code statement.

[0129] In some embodiments, the first neural network model may store first knowledge information specifically used for analyzing and optimizing problematic code statements. For example, the first knowledge information may include one or more problem types and optimization strategies corresponding to each problem type. The specific details of the problem types and the optimization strategies corresponding to each problem type are as described in S302 above and will not be repeated here. Thus, when training the first neural network model, the model can infer the first problem and the first optimization strategy based on the first knowledge information.

[0130] The following is combined with Figure 4 As shown, an exemplary description is given of the structure of a first neural network model storing first knowledge information.

[0131] In some embodiments, such as Figure 4As shown, the first neural network model (such as Tongyi Qianwen) TM A neural network model can include an input layer for receiving input data, n (n is an integer greater than 1) transformation layers, and an output layer for outputting results. The transformation layers are the core components of each neural network model architecture, used to process data sequences. Each transformation layer consists of an attention module and a feedforward network (FFN). The attention module analyzes the dependencies within the data sequence to achieve dynamic context awareness, while the FFN extracts or transforms features from each element in the data sequence, including contextual information.

[0132] Among them, continue to refer to Figure 4 As shown, when the first neural network model includes n Transformer layers, the first knowledge information can be stored in one of the n Transformer layers. For example, the first knowledge information can be stored in the last Transformer layer of the n Transformer layers (as an example of the first network layer), so that the first network layer can infer the first problem existing in the first code statement and the applicable first optimization strategy based on the first knowledge information. Alternatively, the first knowledge information can also be stored in the first Transformer layer of the n Transformer layers or other Transformer layers; this application does not limit this.

[0133] The following will continue to combine Figure 4 Taking the storage of first knowledge information in the last Transformer layer as an example, the process of constructing a first neural network model from a general Transformer neural network is described in an exemplary manner.

[0134] like Figure 4 As shown, when constructing the first neural network model using the Transformer neural network, the structures (such as the number of Transformer layers) and parameters (such as the weight parameters w) in the Transformer neural network can be preserved. k Bias parameter b k (etc.) remain unchanged, only the first knowledge information (such as through the weight parameter w) is added to the last Transformer layer. k1 (This is to be represented) and additional functions (such as the σ activation function) and parameters (such as the bias parameter b) are added for inference computation of code statements. k1(etc.). In this way, since the original structure and parameters of the Transformer neural network are not changed, the constructed first neural network model and the trained second neural network model can maintain the reasoning and generalization ability of the original Transformer neural network; and, by adding first knowledge information and adding some functions and parameters for reasoning and calculating code statements, the first neural network model can also analyze and optimize the problems existing in the code statements.

[0135] In summary, based on the above method, a first neural network model can be constructed. Then, the first neural network model can be trained using training data to obtain a trained second neural network model.

[0136] S3042: Based on the inferred first problem and first optimization strategy, as well as the problem and optimization strategy in the training data, adjust the parameters of the first neural network model to obtain the trained second neural network model.

[0137] In some embodiments, after the electronic device infers a first problem and a first optimization strategy through a first neural network model, the electronic device can calculate the loss value between the first problem and the first optimization strategy and the problem and optimization strategy in the training data based on a loss function. Then, when the loss value is large, the electronic device can adjust the parameters in the first neural network model and re-infer the code statements in the training data until the loss value between the inferred problem and the optimization strategy and the problem and optimization strategy in the training data is minimized when inferring the code statements in the training data based on the adjusted parameters. This indicates that the training process of the first neural network model is complete, thereby obtaining the second neural network model.

[0138] In some embodiments, the parameters of the first neural network model may include first knowledge information, for example, as described above. Figure 4 In the middle, the weight parameter w can be used k1 This represents the first knowledge information. Therefore, adjusting the parameters of the first neural network model means adjusting the first knowledge information stored in the first neural network model to obtain the second knowledge information. Consequently, the trained second neural network model can store second knowledge information for analyzing and optimizing problems in the code statements.

[0139] In some embodiments, such as Figure 4As described in S3041 above, the first neural network model may include n (n is an integer greater than 1) Transformer layers, and the first knowledge information may be stored in the last Transformer layer of the n Transformer layers of the first neural network model (as an example of the first network layer). Therefore, the trained second neural network model may also include n Transformer layers, and the second knowledge information may be stored in the last Transformer layer of the n Transformer layers of the second neural network model (as an example of the second network layer), so that the second network layer can determine the problems existing in the code statement to be processed and the applicable optimization strategy based on the second knowledge information. It is understood that if the first knowledge information is stored in the other i-th (i is a positive integer less than or equal to n) Transformer layer of the n Transformer layers of the first neural network model, then the second knowledge information may also be stored in the other i-th Transformer layer of the n Transformer layers of the second neural network model. This application does not limit this.

[0140] In summary, the above method allows for the construction of a first neural network model storing first knowledge information, and the training process of the first neural network model is completed to obtain a second neural network model. Furthermore, electronic devices can use the second neural network model mentioned in this application to automatically analyze and optimize problems in code statements (such as SQL problems). Moreover, since the neural network model also possesses a certain degree of generalization and reasoning ability, the second neural network model mentioned in this application can handle novel or complex code problems. Additionally, in this application, during the training of the first neural network model, the first knowledge information specifically used for analyzing and optimizing code statements is further adjusted to obtain second knowledge information. This allows the second neural network model to perform more accurate analysis and optimization of code statements using the second knowledge information, resulting in more accurate reasoning results for the code statements. Furthermore, the second neural network model used in this application can be any small-scale neural network model with reasoning capabilities, thereby saving computational and storage resources of the electronic device.

[0141] Furthermore, as mentioned above, the first network layer of the first neural network model stores first knowledge information. That is, the first neural network model mainly infers the first problem and the applicable first optimization strategy of the first code statement based on the first network layer. Therefore, when training the first neural network model with training data, it is also necessary to focus on the training status of the first network layer storing the first knowledge information, so that the second network layer obtained after training the first network layer can more accurately infer the problem and the applicable optimization strategy of the code statement. In other words, in this embodiment of the application, in the process of training the first neural network model with training data to obtain the second neural network model, the electronic device obtains the second network layer in the second neural network model by training the first network layer in the first neural network model.

[0142] For example, an electronic device can infer a first problem and a suitable first optimization strategy from the first knowledge information stored in the first network layer. Then, based on the inferred first problem and first optimization strategy, as well as the problems and optimization strategies in the training data, the electronic device can adjust the parameters of the first network layer in the first neural network model to obtain a second network layer, thus obtaining a second neural network model with a second network layer. In this way, the first network layer storing the first knowledge information in the first neural network model can be trained to obtain the second network layer, enabling the trained second network layer to automatically analyze and optimize problems in the code statement (such as SQL problems).

[0143] The following is combined with Figure 5 The process of training the first network layer in the first neural network model to obtain the second network layer of the second neural network model is described, as shown. This method can be applied to electronic devices, such as any electronic device like the computer mentioned above. Figure 5 As shown, specifically, the method is as follows:

[0144] S501: The first network layer concatenates the various data points in the training data into a structured target data sequence.

[0145] In some embodiments, a data sequence X can be defined in the first network layer to concatenate information such as code statements, table structure and / or index information in the database information of each code statement (also known as metadata information), optimized code statements, and optimization strategies into structured data information. For example, the concatenation function for generating the data sequence X can be referred to as formula (1):

[0146] (1);

[0147] Where X represents the generated data sequence; Concate() represents concatenating multiple data sets; S orig This indicates the encoding of the received code statement to be processed; [SQL_ORIG] indicates the code statement label (such as the SQL label) to indicate the data S orig The semantic role of M is a code statement; meta [META] represents the encoding of table structure (such as partitions) and / or indexes in the database information received by the code statement; [META] represents metadata information tags to indicate data M meta The semantic role of S is database information; opt This indicates the optimized code statement; [TARGET_SQL] represents the expected optimization label to indicate the data S opt The semantic role of E is the optimized code statement; desc Encoding of data such as existing problems, optimization strategies, and / or strategy advantages; [STRATEGY] represents the strategy label to indicate data E. desc The semantic roles are problem, optimization strategy, and / or strategy advantage.

[0148] In some embodiments, when training the first network layer, the first network layer can, based on the above formula (1), concatenate the first code statement in the training data, the table structure and / or index information in the first database information corresponding to the first code statement, the optimized code statement corresponding to the first code statement, and the problems, applicable optimization strategies, and strategy advantages of the first code statement into a target data sequence X.

[0149] For example, if the first code statement is "SELECT * FROM orders WHERE user_id IN (SELECT user_id FROM users WHERE status = 'active')", and the table structure and / or index information in the first database information corresponding to the first code statement is "CREATE TABLE orders (id INT,user_id INT, amountDECIMAL);CREATE INDEX idx_user_id ON orders(user_id);", then the optimized code statement is "SELECT * FROM orders WHERE EXISTS (SELECT 1 FROM users WHERE users.user_id = orders.user_id AND status= 'active')”, the problem (or scenario) of the first code statement is “subquery optimization”, the optimization strategy corresponding to the first code statement is “replacing the IN query with an EXISTS query”, the strategy advantage of the optimization strategy of the first code statement is “rewriting the IN subquery with EXISTS can avoid full table scan, reduce intermediate result sets, and improve performance by 300%”, then the electronic device can generate the target data sequence X corresponding to the first code statement based on the above formula (1) as “[SQL_ORIG] SELECT * FROM orders WHERE user_id IN(SELECT user_id FROM users WHERE status = 'active'); [META] CREATE TABLEorders (id INT,user_id INT, amount DECIMAL);CREATE INDEX idx_user_id ONorders(user_id); [TARGET_SQL] SELECT * FROM orders WHERE EXISTS (SELECT 1 FROM users WHERE users.user_id = orders.user_id AND status= 'active'); [STRATEGY] Scenario: Subquery optimization; Strategy: Replace IN query with EXISTS query; Advantage: Rewriting IN subquery with EXISTS avoids full table scan, reduces intermediate result sets, and improves performance by 300%. In this way, the various data points in the training data can be concatenated into a structured target data sequence.

[0150] It is understood that in some other embodiments, the data sequence X may not include [TARGET_SQL]S. opt In other words, the training data may not include the optimized code statements, but only include information such as the problems of the first code statements and the applicable optimization strategies. This application does not limit this.

[0151] It can also be understood that a code statement to be processed can correspond to a data sequence X. In other words, when training the first network layer with training data composed of multiple code statements, the first network layer can generate a corresponding data sequence X for each code statement, thereby obtaining multiple data sequences X.

[0152] S502: The first code statement in the training data and the table structure and / or index information in the first database information are concatenated into a structured training data sequence through the first network layer.

[0153] In some embodiments, during the model inference phase, when the electronic device generates the data sequence X based on the above formula (1), it may only generate [SQL_ORIG] S. orig Item and [META] M meta After deduce the problems and optimization strategies in the code statements, complete the [TARGET_SQL] section. opt Item and [STRATEGY] E desc Therefore, when training the first neural network model, the electronic device can also first generate [SQL_ORIG] S in the training data sequence X based on the first code statement in the training data and the table structure and / or index information in the first database information. orig Item and [META] M meta After identifying the first problem with the first code statement and the applicable first optimization strategy, the [TARGET_SQL] S in the training data sequence X is then completed. opt Item and [STRATEGY] E desc The item is used to obtain the inference data sequence.

[0154] S503: The first network layer performs inference on the training data sequence based on the first knowledge information to obtain the inference result sequence corresponding to the training data sequence.

[0155] In some embodiments, the first network layer may, based on first knowledge information, reason about the first code statement in the training data sequence X and the table structure and / or index information in the first database information, to analyze the first problem existing in the first code statement and the applicable first optimization strategy, thereby completing the [TARGET_SQL]S in the training data sequence X.opt Item and [STRATEGY] E desc The item obtains a sequence of inference data. That is, the sequence of inference results includes at least a first code statement, table structure and / or index information in the first database information, a first problem existing in the inferred first code statement, and a first optimization strategy applicable to the inferred first code statement. Specifically, the specific process of the electronic device obtaining the sequence of inference results can be found in [reference needed]. Figure 6 As shown, details will not be elaborated here.

[0156] S504: Based on the target data sequence and the corresponding inference result sequence, determine the loss function result of the first network layer.

[0157] In some embodiments, when determining the loss function result of the first network layer, the electronic device may first determine the first loss result of the first network layer based on the target data sequence. The first loss result of the first network layer can be determined using the following formula (2):

[0158] (2);

[0159] Among them, L sql This is the calculated first loss result; y target The target data sequence determined by S501 above; T is the length of the target data sequence, which is the number of feature tokens in the target data sequence; This refers to all tokens preceding the t-th token in the target data sequence, i.e., from the 1st to the (t-1th)th token; h refers to the encoding sequence corresponding to the training data sequence, which can be found in the reference section. Figure 6 As described in S5031; This refers to the probability that the first network layer predicts the t-th token, given the previous 1st to t-1th tokens and the encoding sequence h.

[0160] Thus, using the above formula (2), the electronic device can determine the first loss result L of the first network layer. sql This means determining the generation loss of the first network layer.

[0161] In addition, when determining the loss function result of the first network layer, besides calculating the first loss result, the electronic device can also determine the second loss function of the first network layer based on the FFN result and the inference result sequence. The process of obtaining the FFN result can be referred to Figure 6 As described in S5032, it will not be elaborated here. The first loss result of the first network layer can be determined by the following formula (3).

[0162] (3);

[0163] Among them, L preserve This is the calculated second loss result; E h-D This represents the expectation on the non-code statement optimization scenario dataset; y orig This is the original FFN result; please refer to the details. Figure 6 S5032 and formula (4) are described in detail here; y final Through "y" orig +y patch The final output result is determined, where y patch This is the result of the patch; please refer to the details. Figure 6 The details of S5033 and formulas (5) and (6) are not elaborated here.

[0164] Thus, using the above formula (3), the electronic device can determine the second loss function L of the first network layer. preserve This means that the first network layer retains the original constraint loss.

[0165] Furthermore, the electronic device determines the first loss result L of the first network layer. sql Second loss function L preserve After that, electronic devices can access "L" sql +γL preserve "Determine the final loss function result for the first network layer. Here, γ is the weight coefficient, which can be determined by the developers based on experiments or experience."

[0166] S505: Based on the loss function results and the backpropagation mechanism, adjust the parameters in the first network layer to obtain the second network layer, and obtain the second neural network model with the second network layer.

[0167] In some embodiments, after determining the loss function result, if the loss function result is large, the electronic device can reversely adjust the parameters in the first network layer and re-infer the code statements in the training data until the loss function result is minimized when inferring the code statements in the training data based on the adjusted parameters. This indicates that the training process of the first network layer has been completed, thereby obtaining the second network layer and the second neural network model with the second network layer.

[0168] Thus, by using the above method, the first network layer storing the first knowledge information in the first neural network model can be trained to obtain the second network layer, thereby obtaining a second neural network model with the second network layer.

[0169] Furthermore, such as Figure 5As described in S501 to S505, when training the first network layer, it is necessary to infer the training data sequence through the first network layer to obtain the inference result sequence corresponding to the training data sequence, and then adjust the parameters of the first network layer in reverse based on the loss function result between the inference result sequence and the target data sequence to obtain the second network layer. The following is combined with... Figure 6 The flowchart shown is for Figure 5 The process described in S503 of this paper involves the first network layer inferring from the training data sequence based on first knowledge information to obtain the inference result sequence. This method can be applied to electronic devices, such as any electronic device like the computer mentioned above. Specifically, the method is as follows:

[0170] S5031: Encode the training data sequence to obtain the encoded sequence.

[0171] For example, the encoded sequence h can be obtained by running the code "h=Encode(X)" to encode the training data sequence.

[0172] S5032: Calculate the FFN result corresponding to the encoded sequence based on the FFN function.

[0173] For example, such as Figure 4 As shown, each Transformer layer includes a feedforward neural network, and the original structure of the Transformer layer was not deleted when constructing the first neural network model, that is, the feedforward neural network was not deleted. Therefore, when training the first network layer, the first network layer can also calculate the original FFN result corresponding to the encoded sequence based on the FFN function in the original feedforward neural network. For example, the FFN function can be referred to as the following formula (4):

[0174] (4);

[0175] Among them, y orig It is the calculated FFN result; w k σ is the weight parameter of the second linear transformation layer in the feedforward neural network; w1 is the weight parameter of the first linear transformation layer in the feedforward neural network; h is the encoding sequence obtained by S5031 above; b1 is the bias parameter of the first linear transformation layer in the feedforward neural network; b k These are the bias parameters of the second linear transformation layer in a feedforward neural network.

[0176] It is understandable that the initial values ​​of each parameter in the above formula (4) can be determined by the developers based on experiments or experience. After assigning initial values ​​to each parameter, the electronic device can begin training the first network layer, and then continuously adjust each parameter in reverse during the training process to obtain the second network layer. For details, please refer to [link / reference]. Figure 3B As described in S3041 and S3042, they will not be repeated here.

[0177] S5033: Calculate the gating signal corresponding to the encoded sequence based on the gating function, and when the gating signal indicates that the first neural network model is reasoning about the code statement to be processed, determine the patching result corresponding to the encoded sequence based on the patching function and the first knowledge information.

[0178] In some embodiments, since the original structure of the Transformer layer is not removed when constructing the first neural network model, the first network layer can process not only problematic code statements but also other input data. In this case, the first network layer needs to identify whether the data to be processed is a code statement using the gate signal calculated by the gate function. If not, the patch function can be left unactivated, meaning the first knowledge information can be left unused for reasoning. Conversely, if the first network layer determines that the data to be processed is a code statement using the gate signal calculated by the gate function, then reasoning on the code statement based on the first knowledge information is still required. The gate function can be as shown in formula (5):

[0179] (5);

[0180] Where g(h) is the calculated gating signal; σ is the activation function; h is the encoded sequence obtained by S5031 above; w g and b g These are all gating network parameters, w g It is the weight parameter, b g It is a bias parameter.

[0181] For example, if the gate signal g(h) calculated by formula (5) is close to 0, it means that the data processed by the first neural network model is not code statement, the first network layer can not activate the patch function, that is, it can not use the first knowledge information for reasoning, so that the performance of the first neural network model is close to the performance of the original Transformer neural network.

[0182] For another example, if the gate signal g(h) calculated by formula (5) is close to 1, it indicates that the code statement to be processed is being reasoned through the first neural network model. At this time, the patch function can be activated so that the patch result corresponding to the encoded sequence can be determined based on the patch function and the first knowledge information. The patch function can be shown in formula (6):

[0183] (6);

[0184] Among them, y patch It is the calculated patch result; w k1 It is primary knowledge information, b k1 is the bias parameter, and g(h) is the gate signal calculated by the above formula (5).

[0185] Thus, based on formula (6), the first knowledge information can be applied to the reasoning process of the first code statement. Furthermore, the final output result can be obtained by combining the result of formula (6) with the original FFN result determined by formula (4) above.

[0186] It can be understood that in the above formula (5) or formula (6), except for the parameter w used to represent the first knowledge information, k1 The initial values ​​for all parameters, except for the first one, can be determined by the developers based on experiments or experience. After assigning initial values ​​to each parameter, the electronic device can begin training the first network layer, and then continuously adjust the parameters in reverse during the training process to obtain the second network layer. See details for further information. Figure 3B As described in S3041 and S3042, they will not be repeated here.

[0187] S5034: Based on the FFN results and patch results corresponding to the encoded sequence, determine the inference result sequence of the first network layer for the encoded sequence.

[0188] In some embodiments, the first network layer can be accessed via "y orig +y patch "Determine the final output result y" final , where y orig The original FFN result is determined by the above formula (4), y patch The patching result is calculated using the formula (6) above. Furthermore, after determining the final output result, the [TARGET_SQL]S in the training data sequence X can be completed. opt Item and [STRATEGY] E desc The item is used to obtain the inference data sequence.

[0189] Thus, by executing S5031 to S5034 above, the electronic device can realize the first network layer's inference of the training data sequence based on the first knowledge information to obtain the inference result sequence corresponding to the training data sequence. Furthermore, the electronic device can execute... Figure 5 S504 to S505 are used to adjust the parameters of the first network layer in reverse based on the loss function results between the inference result sequence and the target data sequence to obtain the second network layer.

[0190] The following, in conjunction with Table 2, discusses the above... Figure 5 as well as Figure 6 The overall process of training the first network layer is summarized and introduced below. Specifically, it is shown in Table 2:

[0191] Table 2

[0192]

[0193] It should be understood that Table 2 above only applies to... Figure 5 as well as Figure 6 The diagram shows a simple visual summary of the training process for the first network layer. The specific steps in Table 2 can be found in the provided text. Figure 5 and Figure 6 As shown, no further details will be provided.

[0194] In summary, based on the above method, the first network layer storing the first knowledge information in the first neural network model can be trained to obtain the second network layer, thereby obtaining a second neural network model with the second network layer. This enables the second neural network model to automatically analyze and optimize problems in code statements (such as SQL problems).

[0195] The following is combined with Figure 7 The flowchart shown illustrates the process of automating the analysis and optimization of problems in the code statements processed by the second neural network model. This data processing method can be applied to electronic devices, such as any electronic device like the computer mentioned above.

[0196] It is understood that the second neural network model mentioned in this embodiment is obtained by training using the method described above. Furthermore, in this embodiment, the electronic device that trains the first neural network model to obtain the second neural network model and the electronic device that runs the second neural network model to analyze and optimize the code statements to be processed can be the same or different electronic devices.

[0197] like Figure 7 As shown, the specific data processing method is as follows:

[0198] S701: Obtain the third code statement to be processed and the second database information corresponding to the third code statement.

[0199] In some embodiments, electronic devices can access database systems (such as MySQL). TM The database system retrieves the pending third-party code statements from its slow log. The slow log is a logging mechanism within the database system primarily used to record information about code statements (such as SQL statements) whose execution time exceeds a set time threshold. For example, if the time threshold is set to 5 seconds, the database system can record information about code statements whose execution time exceeds 5 seconds in the slow log for subsequent analysis and optimization.

[0200] Then, after retrieving the third code statement to be processed, the electronic device can obtain the second database information corresponding to the third code statement from the database system. For example, the second database information may include, but is not limited to, one or more types of information such as the database structure (also known as database metadata information), the execution plan of the third code statement, and hardware utilization information. For instance, the database structure is the data organization form and rules created within the database system, and may include, but is not limited to, created tables, data types (such as integer data types), and / or constraints (such as whether an item can be nullable, etc.). The execution plan of the third code statement can be a detailed execution scheme generated by the database system for executing the third code statement, which can be used to show how the database system accesses data, uses indexes, etc., for example, in MySQL. TM In database systems, the "EXPLAIN" field can be added before the third code statement to obtain its execution plan. Hardware utilization information can include I / O or CPU utilization, etc.

[0201] S702: Input the third code statement and the second database information into the second neural network model, and analyze the third code statement and the second database information based on the second knowledge information by running the second neural network model, so as to determine the problems existing in the third code statement and the optimization strategy applicable to the third code statement.

[0202] For example, in other embodiments, after the second neural network model determines the optimization strategy applicable to the third code statement, the second neural network model can also adjust the third code statement according to the optimization strategy applicable to the third code statement, thereby directly outputting the optimized fourth code statement.

[0203] In some embodiments, as described above Figure 4The first neural network model can include n (n is an integer greater than 1) Transformer layers. Therefore, the second neural network model trained based on the first neural network model can also include n Transformer layers. Specifically, the structure of the second neural network model can be referred to... Figure 8 As shown.

[0204] like Figure 8 As shown, the second neural network model may include a first input layer, n Transformer layers, and a first output layer. The first input layer receives the third code statement to be processed and the corresponding second database information. The last Transformer layer among the n Transformer layers (as an example of a second network layer) stores second knowledge information for analyzing and optimizing the code statement, enabling the second network layer to determine the problems in the third code statement and applicable optimization strategies based on this second knowledge information. The first output layer outputs the problems in the third code statement and applicable optimization strategies. Thus, this second neural network model can automatically analyze and optimize problems in code statements (such as SQL problems).

[0205] Understandable, such as Figure 4 As shown, since the first network layer in the first neural network model does not reduce other structures of the Transformer neural network, the second neural network model mentioned in this application, trained based on the first network layer, also does not reduce other structures of the Transformer neural network. This allows the second neural network model to maintain the inference generalization ability of the original Transformer neural network.

[0206] Furthermore, in other embodiments, after the second network layer determines the optimization strategy applicable to the third code statement, it can further adjust the third code statement according to the optimization strategy to obtain an optimized fourth code statement, thereby enabling the first output layer to directly output the optimized fourth code statement. And / or, in other embodiments, after the second network layer determines the optimization strategy applicable to the third code statement, it can also determine the strategy advantage corresponding to the optimization strategy applicable to the third code statement, thereby enabling the first output layer to output the strategy advantage corresponding to the optimization strategy applicable to the third code statement. For example, when training the first network layer, the training data can also include the strategy advantages brought by the optimization strategies for the first network layer to learn. In this way, the second network layer trained based on the first network layer can analyze the strategy advantages corresponding to each optimization strategy.

[0207] Understandable, with Figure 5 and Figure 6 The reasoning process involved in training the first network layer is similar. When the second network layer analyzes the third code statement and the second database information, it also needs to determine the problems and applicable optimization strategies of the third code statement based on the above formulas (1) and (4) to (6). Specifically, the second network layer can first construct the data sequence X through formula (1), then encode the data sequence X to obtain the encoded sequence h, and then determine the original FFN result y corresponding to the encoded sequence x through formula (4). orig Then, the gating signal g(h) corresponding to the encoded sequence x is calculated using formula (5), and the patch result y is calculated using formula (6) when the gating signal g(h) is close to 1 to indicate that the second network layer is processing code statements. patch Finally, the result y can be obtained through FFN. orig And patch results y patch Determine the final output of the second network layer (e.g., y). orig +y patch Furthermore, the second network layer can pass the final output to the first output layer of the second neural network model for output.

[0208] Thus, through the above method, electronic devices can automatically analyze and optimize problems in code statements (such as SQL problems). Furthermore, since neural network models also possess a certain degree of generalization and reasoning ability, electronic devices can analyze new or complex code problems based on a second neural network model and deduce suitable optimization strategies for these problems. In addition, the second neural network model mentioned in this application contains second knowledge information specifically used for analyzing and optimizing code statements. This second knowledge information is obtained by further adjusting the first knowledge information specifically used for analyzing and optimizing code statements during the training of the first neural network model. This allows the second neural network model to perform more accurate analysis and optimization of code statements using the second knowledge information, thereby making the reasoning results of the electronic device when reasoning about code statements based on the second neural network model more accurate. Moreover, the second neural network model used in this application can be any small-scale neural network model with reasoning capabilities, thereby saving computational and storage resources of the electronic device. Furthermore, since the second neural network model does not change the structure of the original Transformer neural network, it can maintain the reasoning generalization ability of the original Transformer neural network. That is, electronic devices can also use the second network model to perform reasoning analysis on other types of data (such as image data).

[0209] The second neural network model provided in this application (such as the one based on Tongyi Qianwen-7B-Chat) is described below in conjunction with Table 3. TM The performance of the constructed and trained Transformer neural network (such as Tongyi Qianwen-72B-Chat) and the performance of the original Transformer neural network (such as Tongyi Qianwen-72B-Chat) are comparable. TM The performance of (etc.) is compared. Specifically, as shown in Table 3:

[0210] Table 3

[0211]

[0212] This is understandable, especially considering the stronger reasoning abilities of the Tongyi Thousand Questions-72B-Chat. TM In comparison, the general questions and answers in the 7B-Chat section, which have weaker reasoning abilities, are more challenging. TM The required storage and computing resources are relatively small. Therefore, as shown in Table 3, it is comparable to Tongyi Qianwen-72B-Chat. TM In comparison, in Tongyi Qianwen-7B-Chat TM The deployment cost (such as storage and computing resource costs) of the second neural network model built and trained on this basis is lower. For example, the second neural network model can be directly deployed on a single RT×3090 graphics card with only 24GB of video memory. TM Above, and Tongyi Qianwen-72B-Chat TM It can only be deployed on high-end processors with multiple GPUs (such as those with eight 40GB VRAMs).

[0213] Additionally, under normal circumstances, it is related to Tongyi Qianwen-72B-Chat. TM Compared to reasoning ability, Tongyi Thousand Questions-7B-Chat TM Poor reasoning ability led to the lack of understanding of the general principles in the 1000 Questions - 7B - Chat TM The inference accuracy and inference cost (also known as inference time) for code statements are both poor. However, in the embodiments of this application, due to the fact that in Tongyi Qianwen-7B-Chat TM The second neural network model, built and trained on this basis, stores second-level knowledge information for analyzing and optimizing problematic code statements, and generates a large amount of training data through decision trees (also known as incorporating decision trees). This allows the second neural network model to outperform Tongyi Qianwen-72B-Chat in terms of both reasoning accuracy and reasoning cost when reasoning about code statements. TM .

[0214] Furthermore, because the second neural network model has a higher reasoning accuracy when reasoning about code statements, it is superior to the Tongyi Qianwen-72B-Chat. TMFurthermore, the optimized code statements inferred by the second neural network model also bring significant performance gains (PG) to the database system.

[0215] Furthermore, as shown in Table 3, since the number of newly added parameters in the first neural network model (such as the parameters of the gating function, the parameters of the patching function, and the first knowledge information) is relatively small, the training cost of training the first neural network model to obtain the second neural network model is also low. For example, only 16GB of video memory is needed to train the first neural network model to obtain the second neural network model. (And, Tongyi Qianwen-72B-Chat) TM Although it can be used directly without training, Tongyi Qianwen-72B-Chat TM The number of parameters itself is enormous, Tongyi Qianwen-72B-Chat TM The model itself requires eight A100 graphics cards (equivalent to eight 40GB VRAMs) to run. Therefore, it is more efficient than directly using the Tongyi Qianwen-72B-Chat. TM Compared to using the second method, the training cost of rebuilding and training the second neural network model is also lower.

[0216] Furthermore, since the second neural network model did not change the original general meaning of the question-7B-Chat TM Because of its structure, the second network model can also perform reasoning analysis on other types of data (such as image data). That is, the reasoning ability (also known as knowledge retention) of the second neural network model in the non-code domain is almost unaffected. For example, as shown in Table 3, the knowledge retention of the second neural network model in the non-code domain can be as high as 99.2%.

[0217] In summary, compared with the original Transformer neural network, the second neural network model provided in this application has significant advantages in terms of inference, the performance gains of the inferred optimized code statements for the database system, training cost, inference cost, knowledge retention, and deployment cost.

[0218] The following is combined with Figure 9 and Figure 10 As shown, the process of constructing a decision tree, training a first neural network model to obtain a second neural network model, and using the second neural network model to process code statements is described holistically. This process can be applied to electronic devices, such as any electronic device like the computer mentioned above. Figure 8 As shown, specifically, the method is as follows:

[0219] S901: Obtain the third code statement to be optimized from the slow log of the database system.

[0220] For example, slow logs are primarily used to record information about code statements whose execution time exceeds a set time threshold. For instance, if the time threshold is set to 5 seconds, the database system can record information about code statements whose execution time exceeds 5 seconds in the slow log for subsequent analysis and optimization.

[0221] S902: Obtain the database structure and indexes, as well as execution information such as the execution plan of the third code statement.

[0222] It is understandable that information such as the database structure, indexes, and execution plan of the third code statements may be part of the second database information corresponding to the third code mentioned above.

[0223] For example, a database structure is the organization and rules of data created within a database system. For instance, a database structure may include, but is not limited to, data types (e.g., a data type can be an integer) and / or constraints (e.g., whether an item can be nullable, etc.).

[0224] For example, database indexes can be used to quickly retrieve data in a database system. When writing code statements to be optimized, the index can also be used to query the corresponding data or perform operations on the data.

[0225] For example, an execution plan is a detailed execution scheme generated by a database system for executing a code statement. It can be used to show how the database system accesses data, uses indexes, and other information. For example, in MySQL... TM In database systems, you can add the "EXPLAIN" field before an SQL statement to obtain the execution plan of the SQL statement to be optimized, such as the indexes used and the number of table rows scanned.

[0226] For example, the electronic device can also obtain other execution information such as the execution time of the code statement to be optimized.

[0227] S903: Obtain hardware utilization information such as CPU and I / O.

[0228] It is understandable that hardware utilization information such as CPU and I / O may also be part of the second database information corresponding to the third code mentioned above.

[0229] For example, IO can refer to disk IO involving reading or writing data from a disk or memory cache IO involving reading or writing data from a memory cache.

[0230] S904: Construct relevant information such as prompt words, and submit the relevant information as context to the second neural network model.

[0231] For example, the prompt words can refer to the third code statement obtained in S901 above, and the database information corresponding to the third code statements obtained in S902 and S903 above. By inputting the prompt words into the second neural network model, the second neural network model can analyze the actual database business.

[0232] The process of obtaining the second neural network model can be referred to as S9041 to S9043 below:

[0233] S9041: Construct a decision tree.

[0234] The following is combined with Figure 10 The diagram illustrates an exemplary description of the structure of a decision tree (also known as a knowledge decision tree).

[0235] like Figure 10 As shown, the decision tree 00 may include an input layer 01, a problem identification layer 02, an optimization strategy selection layer 03, and an execution layer 04.

[0236] The input layer 01 can be used to receive the first code statement and the first database information as input data for the decision tree 00. For example, the first database information may include, but is not limited to, one or more types of information such as the database structure (also known as database metadata information), the execution plan of the first code statement, and hardware utilization information. See details for further information. Figure 3A As described in S301, it will not be repeated here.

[0237] Problem identification layer 02 can analyze the first code statement and the first database information from input layer 01 based on one or more pre-stored problem types to determine whether the problem in the first code statement belongs to the first problem type. For example, problem identification layer 02 can pre-store one or more problems such as subqueries, multi-table JOINs, aggregations, DISTINCT, complex expressions, window functions, or indexes. See details for further information. Figure 3A As described in S302, it will not be repeated here.

[0238] The optimization strategy selection layer 03 can determine the applicable optimization strategy for the first code statement based on the pre-stored optimization strategies corresponding to each problem type (including the optimization strategy corresponding to the first problem type) and the first problem type present in the first code statement from the problem identification layer 02. For example, the optimization strategy selection layer 03 can store optimization strategies applicable to subquery problems: replacing the query statement with the "IN" field with the query statement with the "EXIST" field, or converting the subquery statement into a flattening strategy of equivalent joins, etc.; or, the optimization strategy selection layer 03 can also store optimization strategies applicable to multi-table JOIN problems: reordering strategies that adjust the join order of each table, or strategies that replace the "LEFT JOIN" operation with the "INNER JOIN" operation, etc. Further details are omitted here. See the relevant documentation for more information. Figure 3A As described in S302, it will not be repeated here.

[0239] Execution layer 04, based on the first problem type of the first code statement from optimization strategy selection layer 03 and the applicable optimization strategy for the first code statement, outputs the problem and applicable optimization strategy of the first code statement as output data for decision tree 00. For example, information such as the first problem type of the first code statement and the applicable optimization strategy can be added to the optimization description output by execution layer 04. See details for further information. Figure 3A As described in S302, it will not be repeated here.

[0240] And / or, in other embodiments, execution layer 04 may further adjust the first code statement according to the optimization strategy applicable to the first code statement to generate an optimized second code statement. And / or, execution layer 04 may also output the adjusted portion of the optimized second code statement relative to the first code statement. For example, execution layer 04 may also output the adjusted portion of the second code statement relative to the first code statement by adding comments, wherein the optimized second code statement is obtained by execution layer 04 adjusting the first code statement based on the optimization strategy applicable to the first code statement. And / or, execution layer 04 may also determine the strategy advantage corresponding to the optimization strategy applicable to the first code statement. For example, the strategy advantage of the optimization strategy corresponding to each problem type may be stored in the optimization strategy selection layer 03, and then the strategy advantage corresponding to the optimization strategy applicable to the first code statement may be added to the optimization description output by execution layer 04. See details for further information. Figure 3A As described in S302, it will not be repeated here.

[0241] In this way, electronic devices can be constructed as... Figure 10 The decision tree 00 is shown. Then, the electronic device can execute S9042 to incorporate the decision tree into the first neural network model.

[0242] S9042: Integrate decision trees into the first neural network model.

[0243] In some embodiments, incorporating a decision tree into a first neural network model can refer to generating a large amount of training data by running the decision tree and training the first neural network model based on that training data.

[0244] Specifically, electronic devices in constructing such Figure 10 Following the decision tree 00 shown, the electronic device can analyze a large number of code statements to be processed and database information by running the decision tree 00 to determine the problems existing in the code statements to be processed and the corresponding optimization information. Furthermore, a large amount of training data can be quickly generated for training the first neural network model, ensuring sufficient training samples and a more thorough training process for the first neural network model.

[0245] The following example uses SQL statements as code statements. Combined with Tables 4 to 6, it illustrates how electronic devices can analyze a large number of code statements to be processed and database information by running a decision tree to identify the problems in the code statements to be processed and the corresponding optimization information.

[0246] Table 4

[0247]

[0248] Table 5

[0249]

[0250] Table 6

[0251]

[0252] Based on Tables 4 to 6 above, it can be seen that after constructing a decision tree for processing SQL statements, the electronic device can quickly analyze a large number of SQL statements and corresponding database information through the decision tree to determine the problems (also known as optimization scenarios), applicable optimization strategies, strategy advantages, and optimized SQL statements of each SQL statement, thereby quickly obtaining a large amount of training data so as to fully train the first neural network model through the training data.

[0253] S9043: Obtain the second neural network model.

[0254] In some embodiments, after executing S9042 to generate a large amount of training data through a decision tree to train the first neural network model, the electronic device can obtain the second neural network model. Then, S905 can be executed to process the third code statement to be optimized using the second neural network model.

[0255] S905: The problems in the third code statement are identified through the second neural network model.

[0256] S906: Output optimization scheme.

[0257] The specific implementation process of S905 and S906 mentioned above can be found in [reference]. Figure 7 As shown, no further details will be provided.

[0258] Thus, through the above method, a decision tree can be constructed, a first neural network model can be trained to obtain a second neural network model, and the second neural network model can be used to reason about code statements. Specifically, the electronic device can quickly generate a large amount of training data based on the decision tree to rapidly and fully train the first neural network model to obtain the second neural network model. Furthermore, the electronic device can use the second neural network model mentioned in this application to automatically analyze and optimize problems in code statements (such as SQL problems). Moreover, since the neural network model also possesses a certain degree of generalization and reasoning ability, the second neural network model mentioned in this application can analyze new or complex code problems and deduce optimization strategies applicable to these problems.

[0259] Furthermore, in some embodiments, this application also provides a readable storage medium. The readable storage medium stores instructions that, when executed on an electronic device, cause the electronic device to perform the training method or data processing method for the neural network model mentioned in this application.

[0260] Furthermore, in other embodiments, this application also provides a computer program product, wherein the computer program product includes computer instructions. When the computer instructions are executed on an electronic device, the electronic device enables the electronic device to implement the training method or data processing method of the neural network model mentioned in this application.

[0261] Furthermore, in some other embodiments, this application also provides a chip including a processor. The processor is used to read and execute computer code / instructions stored in memory to perform the training method or data processing method of the neural network model mentioned in this application.

[0262] Furthermore, in other embodiments, this application also provides an electronic device. The electronic device includes at least one memory and at least one processor, with the memory coupled to the processor. The memory stores computer program code / instructions. When the computer program code / instructions are executed by the processor, the electronic device can implement the training method or data processing method of the neural network model mentioned in this application.

[0263] like Figure 11 The diagram illustrates the hardware structure of an electronic device 100 according to an embodiment of this application. Figure 11 As shown, the electronic device 100 may include one or more processors 102, a system control logic unit 101 connected to at least one of the processors 102, a system memory 105 connected to the system control logic unit 101, a memory 103 connected to the system control logic unit 101, and a network interface 107 connected to the system control logic unit 101.

[0264] It is understood that the structures illustrated in the embodiments of this application do not constitute a limitation on the only possible implementation of the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0265] Processor 102 may include one or more single-core or multi-core processors. In some embodiments, processor 102 may include any combination of general-purpose processors and special-purpose processors (e.g., application processors, baseband processors, etc.). It is understood that in this embodiment, processor 102 may be configured to execute executable instructions 104 stored in memory 103 to implement the neural network model training method or data processing method of this embodiment. When at least one instruction is executed in processor 102, electronic device 100 implements the neural network model training method or data processing method of this embodiment.

[0266] System control logic unit 101 may include any suitable interface controller to provide any suitable interface to at least one of the processors 102 and / or any suitable device or component communicating with system control logic unit 101. System control logic unit 101 may include one or more memory controllers to provide an interface to system memory 105. System memory 105 may be used to load and store data and / or instructions. In some embodiments, system memory 105 of electronic device 100 may include any suitable volatile memory, such as suitable dynamic random access memory.

[0267] Memory 103 may include one or more tangible, non-transitory computer-readable media for storing data and / or instructions. In some embodiments, memory 103 may include any suitable volatile memory and / or any suitable non-volatile storage device, such as memory 103 may include random access memory (RAM) and / or cache memory cells, and may further include read-only memory (ROM).

[0268] The memory 103 may include a portion of the storage resources on the device on which the electronic device 100 is installed, or it may be accessible by the device, but is not necessarily part of the device. For example, the memory 103 may be accessed over a network via the network interface 107.

[0269] Specifically, system memory 105 and memory 103 may each include a temporary copy and a permanent copy of instruction 104. Instruction 104 may include a training method or data processing method that, when executed by at least one of processors 102, causes electronic device 100 to implement the neural network model of the embodiments of this application. In some embodiments, instruction 104, hardware, firmware, and / or its software components may additionally / alternatively be located in system control logic unit 101, network interface 107, and / or processor 102.

[0270] Network interface 107 may include a transceiver for providing a radio interface to electronic device 100, thereby enabling communication with any other suitable device (such as a front-end module, antenna, etc.) via one or more networks. In some embodiments, network interface 107 may be integrated into other components of electronic device 100. For example, network interface 107 may be integrated into at least one of processor 102, system memory 105, memory 103, and firmware device (not shown) with instructions.

[0271] Network interface 107 may further include any suitable hardware and / or firmware to provide a multiple-input multiple-output radio interface. For example, network interface 107 may be a network adapter, a wireless network adapter, a telephone modem, and / or a wireless modem.

[0272] The electronic device 100 may further include an input / output (I / O) device 106. The input / output device 106 enables a user to interact with the electronic device 100.

[0273] In some embodiments, the electronic device 100 may further include, but is not limited to, a display (e.g., a liquid crystal display, a touch screen display, etc.), a speaker, a microphone, one or more cameras (e.g., a still image camera and / or a video camera), a flashlight (e.g., a light-emitting diode flash) and a keyboard.

[0274] In some embodiments, the electronic device 100 further includes a sensor for determining at least one of environmental conditions or location information associated with the electronic device 100.

[0275] In some embodiments, the sensor may include, but is not limited to, a gyroscope sensor, an accelerometer, a proximity sensor, an ambient light sensor, and a positioning unit. The positioning unit may also be part of or interact with the network interface 107 to communicate with components of the positioning network, such as global positioning system (GPS) satellites.

[0276] The embodiments disclosed in this application can be implemented in hardware, software, firmware, or a combination of these implementation methods. Embodiments of this application can be implemented as computer programs or program code executable on a programmable system, the programmable system including at least one processor, a storage system (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device.

[0277] Program code can be applied to input instructions to execute the functions described in this application and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, the processing system includes any system having a processor such as, for example, a digit gate processor, a microcontroller, an application-specific integrated circuit, or a microprocessor.

[0278] The program code can be implemented using a high-level procedural language or an object-oriented programming language to communicate with the processing system. Assembly language or machine language can also be used when needed. In fact, the mechanisms described in this application are not limited to any particular programming language. In either case, the language can be a compiled language or an interpreted language.

[0279] In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried or stored thereon on one or more temporary or non-temporary machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors. For example, the instructions may be distributed via a network or through other computer-readable media. Therefore, machine-readable media may include any mechanism for storing or transmitting information in a machine-readable (e.g., computer-readable) form, including but not limited to floppy disks, optical disks, optical discs, magneto-optical disks, ROM, RAM, magnetic cards or optical cards, or tangible machine-readable memories for transmitting information using electrical, optical, acoustic, or other forms of propagation signals via the Internet (e.g., carrier waves, infrared signal digit gating, etc.). Therefore, machine-readable media include any type of machine-readable medium suitable for storing or transmitting electronic instructions or information in a machine-readable (e.g., computer-readable) form.

[0280] In the accompanying drawings, some structural or methodological features may be shown in a specific arrangement and / or order. However, it should be understood that such a specific arrangement and / or order may not be necessary. Rather, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. Furthermore, including structural or methodological features in a particular figure does not imply that such features are required in all embodiments, and in some embodiments, these features may be omitted or may be combined with other features.

[0281] It should be noted that all units / modules mentioned in the device embodiments of this application are logical units / modules. Physically, a logical unit / module can be a physical unit / module, a part of a physical unit / module, or a combination of multiple physical units / modules. The physical implementation of these logical units / modules themselves is not the most important factor; the combination of functions implemented by these logical units / modules is the key to solving the technical problems proposed in this application. Furthermore, to highlight the innovative aspects of this application, the above-described device embodiments of this application have not introduced units / modules that are not closely related to solving the technical problems proposed in this application. This does not mean that the above-described device embodiments do not contain other units / modules.

[0282] It should be noted that in the examples and description of this application, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one" does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0283] Although this application has been illustrated and described with reference to certain preferred embodiments thereof, those skilled in the art will understand that various changes in form and detail may be made thereto without departing from the scope of this application.

Claims

1. A method for training a neural network model, characterized in that, Applied to electronic devices, the method includes: Obtain the first code statement to be processed and the first database information corresponding to the first code statement; The decision tree is used to process the first code statement and the first database information to generate the problems existing in the first code statement and the applicable optimization strategies. The training data is determined based on the first information, which includes the first code statement, the first database information, the problems existing in the first code statement, and the optimization strategy applicable to the first code statement. The first neural network model is trained using the training data to obtain the trained second neural network model; In the process of training the first neural network model using the training data, the first problem and the applicable first optimization strategy for the first code statement applied to the first database information are inferred from the first knowledge information stored in the first neural network model for analyzing and optimizing problems in the code statement. Based on the inferred first problem and the first optimization strategy, as well as the problems and optimization strategies in the training data, the parameters of the first neural network model are adjusted. The parameters of the first neural network model include the first knowledge information. This results in a trained second neural network model. The second neural network model stores second knowledge information for analyzing and optimizing problems in the code statement. The second knowledge information is obtained by adjusting the first knowledge information in the parameters of the first neural network model.

2. The method according to claim 1, characterized in that, The step of processing the first code statement and the first database information through a decision tree to generate the problems existing in the first code statement and the applicable optimization strategies includes: The decision tree analyzes the first code statement and the first database information based on one or more pre-stored problem types to determine that the problem in the first code statement belongs to the first problem type. The decision tree determines the optimization strategy applicable to the first code statement based on the pre-stored optimization strategies corresponding to each problem type, wherein the optimization strategy corresponding to each problem type includes the optimization strategy corresponding to the first problem type.

3. The method according to claim 2, characterized in that, The method further includes: The decision tree adjusts the first code statement based on the optimization strategy applicable to the first code statement to obtain the optimized second code statement; Furthermore, the first information also includes the second code statement.

4. The method according to claim 2 or 3, characterized in that, The method further includes: The decision tree determines the strategy advantage corresponding to the optimization strategy applicable to the first code statement, and the first information further includes the strategy advantage; and / or, The decision tree determines the adjustment portion of the optimized second code statement relative to the first code statement. The first information also includes the adjustment portion of the second code statement relative to the first code statement. The second code statement is obtained by the decision tree adjusting the first code statement based on the optimization strategy applicable to the first code statement.

5. The method according to claim 1, characterized in that, The decision tree includes an input layer, a problem identification layer, an optimization strategy selection layer, and an execution layer. The process of processing the first code statement and the first database information using the decision tree to generate the problems existing in the first code statement and the applicable optimization strategies includes: The input layer receives the first code statement and the first database information as input data for the decision tree; The problem identification layer analyzes the first code statement from the input layer and the first database information based on one or more pre-stored problem types to determine that the problem in the first code statement belongs to the first problem type. The optimization strategy selection layer determines the optimization strategy applicable to the first code statement based on the pre-stored optimization strategies corresponding to each problem type and the first problem type present in the first code statement from the problem identification layer, wherein the optimization strategy corresponding to each problem type includes the optimization strategy corresponding to the first problem type; The execution layer outputs the problem and the applicable optimization strategy of the first code statement based on the first problem type of the first code statement from the optimization strategy selection layer, as the output data of the decision tree.

6. The method according to claim 5, characterized in that, The method further includes: The execution layer adjusts the first code statement based on an optimization strategy applicable to the first code statement to obtain an optimized second code statement, wherein the first information further includes the second code statement; and / or, The execution layer determines the strategy advantage corresponding to the optimization strategy applicable to the first code statement, and the first information further includes the strategy advantage; and / or, The execution layer determines the adjusted portion of the optimized second code statement relative to the first code statement. The first information also includes the adjusted portion. The second code statement is obtained by the execution layer adjusting the first code statement based on the optimization strategy applicable to the first code statement.

7. The method according to any one of claims 1 to 6, characterized in that, The first neural network model includes a first network layer, which stores the first knowledge information. The first network layer can be used to infer, based on the first knowledge information, the first problem existing in the first code statement applied to the first database information and the applicable first optimization strategy. and, In the process of training the first neural network model using the training data, the first problem existing in the first code statement applied to the first database information and the applicable first optimization strategy are inferred from the first knowledge information stored in the first neural network model for analyzing and optimizing problems in code statements. Based on the inferred first problem and first optimization strategy, as well as the problems and optimization strategies in the training data, the parameters of the first neural network model are adjusted to obtain the trained second neural network model, including: During the training of the first neural network model using the training data, the first problem and the applicable first optimization strategy of the first code statement are inferred from the first knowledge information stored in the first network layer of the first neural network model. Based on the inferred first problem and the first optimization strategy, as well as the problems and optimization strategies in the training data, the parameters of the first network layer in the first neural network model are adjusted to obtain a second network layer, and a second neural network model with the second network layer is obtained. The second network layer stores the second knowledge information and can be used to determine the problem and the applicable optimization strategy of the code statement to be processed based on the second knowledge information.

8. The method according to claim 7, characterized in that, In the process of training the first neural network model using the training data, the first problem existing in the first code statement and the applicable first optimization strategy are inferred from the first knowledge information stored in the first network layer of the first neural network model. Based on the inferred first problem and the first optimization strategy, as well as the problems and optimization strategies in the training data, the parameters of the first network layer in the first neural network model are adjusted to obtain a second network layer, and a second neural network model with the second network layer is obtained, including: The first network layer concatenates the various data points in the training data into a structured target data sequence. The first network layer concatenates the first code statement in the training data and the table structure and / or index information in the first database information into a structured training data sequence. The first network layer infers the training data sequence based on the first knowledge information to obtain the inference result sequence corresponding to the training data sequence; wherein, the inference result sequence includes at least the first code statement, the table structure and / or index information in the first database information, the first problem existing in the inferred first code statement, and the first optimization strategy applicable to the inferred first code statement. Based on the target data sequence and the corresponding inference result sequence, the loss function result of the first network layer is determined; Based on the loss function results and the backpropagation mechanism, the parameters in the first network layer are adjusted to obtain the second network layer, and a second neural network model with the second network layer is obtained.

9. The method according to claim 8, characterized in that, The step of reasoning about the training data sequence based on the first knowledge information through the first network layer to obtain the reasoning result sequence corresponding to the training data sequence includes: The training data sequence is encoded to obtain an encoded sequence; The FFN result corresponding to the encoded sequence is calculated based on the feedforward neural network FFN function; The gating signal corresponding to the encoded sequence is calculated based on the gating function, and when the gating signal indicates that the first neural network model is reasoning about the code statement to be processed, the patching result corresponding to the encoded sequence is determined based on the patching function and the first knowledge information. Based on the FFN result and the patch result corresponding to the encoded sequence, the inference result sequence of the first network layer for the encoded sequence is determined.

10. The method according to claim 9, characterized in that, The step of determining the loss function result of the first network layer based on the target data sequence and the corresponding inference result sequence includes: The first loss result of the first network layer is determined based on the target data sequence; Based on the FFN results and the inference result sequence, the second loss result of the first network layer is determined; Based on the first loss result and the second loss result, the loss function result of the first network layer is determined.

11. The method according to any one of claims 7 to 10, characterized in that, The first neural network model includes n Transformer layers, and the second neural network model includes n Transformer layers. The first network layer is the last Transformer layer among the n Transformer layers of the first neural network model, and the second network layer is the last Transformer layer among the n Transformer layers of the first neural network model, where n is an integer greater than 1.

12. The method according to any one of claims 7 to 11, characterized in that, The second network layer is further configured to optimize the code statement to be processed according to the optimization strategy corresponding to the code statement to be processed, to obtain the optimized target code statement; and / or, The second network layer is also used to determine the strategy advantage corresponding to the optimization strategy applicable to the code statement to be processed.

13. A data processing method, characterized in that, Applied to electronic devices, the method includes: Obtain the third code statement to be processed and the second database information corresponding to the third code statement; The third code statement and the second database information are input into the second neural network model. By running the second neural network model, the third code statement and the second database information are analyzed based on the second knowledge information to determine the problems existing in the third code statement and the optimization strategy applicable to the third code statement; wherein, The second neural network model is obtained by training the first neural network model with training data. The training data is determined based on first information, which includes the first code statement to be processed, the first database information corresponding to the first code statement, and the problems existing in the first code statement and the optimization strategy applicable to the first code statement determined based on the decision tree. In the process of training the first neural network model using the training data, the first neural network model can infer, based on stored first knowledge information used to analyze and optimize problems in code statements, the first problem existing in the first code statement applied to the first database information and the applicable first optimization strategy. Furthermore, the inferred first problem and the first optimization strategy, as well as the problems and optimization strategies in the training data, can be used to adjust the parameters of the first neural network model to obtain the trained second neural network model. The parameters of the first neural network model include the first knowledge information, and the second neural network model stores second knowledge information used to analyze and optimize problems in code statements. The second knowledge information is obtained by adjusting the first knowledge information in the parameters of the first neural network model.

14. The method according to claim 13, characterized in that, The method further includes: By using the second neural network model, the third code statement is adjusted based on the optimization strategy applicable to the third code statement to obtain the optimized fourth code statement.

15. The method according to claim 13 or 14, characterized in that, The second neural network model includes a first input layer, n Transformer layers, and a first output layer, where n is an integer greater than 1; where, The first input layer is used to receive the third code statement to be processed and the second database information corresponding to the third code statement; The second neural network model includes a second network layer, which is the last Transformer layer among n Transformer layers. The second network layer stores second knowledge information for analyzing and optimizing problems in code statements, and is used to determine the problems existing in the third code statement to be processed and the applicable optimization strategies based on the second knowledge information. The first output layer is used to output the problems existing in the third code statement to be processed and the applicable optimization strategies.

16. The method according to claim 15, characterized in that, The method further includes: The second network layer optimizes the third code statement according to the optimization strategy corresponding to the third code statement to obtain an optimized fourth code statement, and the optimized fourth code statement is output through the first output layer; and / or, The second network layer determines the strategy advantage corresponding to the optimization strategy applicable to the third code statement, and the first output layer outputs the strategy advantage corresponding to the optimization strategy applicable to the third code statement.

17. The method according to any one of claims 13 to 16, characterized in that, The acquisition of the third code statement to be processed and the corresponding second database information includes: The third code statement is retrieved from the slow log of the database system, and the second database information corresponding to the third code statement is obtained from the database system.

18. An electronic device, characterized in that, include: At least one memory and at least one processor, the memory being coupled to the processor; the memory being used to store computer program code / instructions; when the computer program code / instructions are executed by the processor, causing the electronic device to perform a training method for a neural network model as described in any one of claims 1 to 12, or to perform a data processing method as described in any one of claims 13 to 17.

19. A readable storage medium, characterized in that, The readable storage medium stores instructions that, when executed on an electronic device, cause the electronic device to perform a training method for a neural network model as described in any one of claims 1 to 12, or to perform a data processing method as described in any one of claims 13 to 17.

20. A computer program product, characterized in that, include: Computer instructions, when executed on an electronic device, cause the electronic device to perform a training method for a neural network model as described in any one of claims 1 to 12, or to perform a data processing method as described in any one of claims 13 to 17.