A method and device for analyzing performance of an SQL statement

By combining static and dynamic methods to analyze SQL statements, generating syntax trees and building neural network regression models, this approach solves the problems of existing tools having rigid inspection rules and failing to analyze dynamic execution, thus achieving more efficient SQL statement performance analysis and optimization.

CN115687050BActive Publication Date: 2025-11-04INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211426900.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-15
Publication Date
2025-11-04
Estimated Expiration
2042-11-15

AI Technical Summary

Technical Problem

Existing static code analysis tools have several drawbacks when analyzing SQL statements. They have rigid inspection rules that are difficult to adapt to actual business needs, they are not run in a real database environment, which leads to inspection errors, and they fail to analyze dynamic execution effects, resulting in long inspection processes and cycles, which affect software delivery.

Method used

By combining static and dynamic analysis, SQL statements are parsed using feature attributes to generate syntax trees. Static analysis parameters such as table data volume, statement complexity, and index matching degree are calculated. Combined with dynamic execution information such as execution time and lock wait time, a neural network regression model is constructed for comprehensive analysis.

Benefits of technology

It improves the accuracy and efficiency of SQL statement performance analysis, enhances the efficiency of SQL statement writing and optimization in the software development process, and strengthens intelligent analysis capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115687050B_ABST
    Figure CN115687050B_ABST
Patent Text Reader

Abstract

The application provides a performance analysis method and device of a SQL statement, relates to the field of artificial intelligence, and can also be used in the field of finance.The method comprises the following steps: analyzing source code to be analyzed according to characteristic attributes of the source code to be analyzed, so as to obtain corresponding SQL statements to be analyzed; the characteristic attributes at least include table data volume, statement quantity and index parameters; performance analysis parameters of the SQL statements to be analyzed are determined according to the characteristic attributes; the performance analysis parameters include static analysis parameters and dynamic analysis parameters; the static analysis parameters and the dynamic analysis parameters are input into a pre-constructed SQL statement performance analysis model, so as to obtain corresponding performance analysis results.The application can analyze the performance of SQL statements in source code to be analyzed in a static-dynamic combination mode.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of artificial intelligence, and can be used in the financial field, in particular to a performance analysis method and device for SQL statements. BACKGROUND

[0002] With the continuous improvement of people's demand for software application, the cycle from demand to development delivery of software version is getting shorter and shorter. As an important part of checking code quality, static code scanning can quickly locate potential errors in the code, find inferior code, and propose corresponding code optimization suggestions before the project coding is submitted.

[0003] However, the existing static code scanning tool has at least the following problems when analyzing the static parameters of the SQL statements in the source code: first, the existing static code scanning tool focuses on analyzing the syntax of the SQL statements. When analyzing, the corresponding checking rules are formed according to the writing specifications of the SQL statements. To some extent, the checking rules are relatively stereotyped and difficult to adapt to various actual business needs, causing false positives. Second, the existing static code scanning tool does not run the corresponding code in the actual database environment when checking the SQL statements, causing certain checking errors. Third, the existing static code scanning tool does not check the real execution effect of the SQL statements in the dynamic execution process, and does not analyze the running efficiency of the SQL statements in combination with the actual data distribution and data volume, resulting in that the efficiency check can only be performed manually. In summary, the existing static code scanning tool has long troubleshooting process and long cycle when checking the SQL statements, which reduces the efficiency of the continuous integration process and affects the software delivery. SUMMARY

[0004] In view of the problems in the prior art, the present application provides a performance analysis method and device for SQL statements, which can analyze the performance of the SQL statements in the source code to be analyzed by combining static and dynamic methods.

[0005] To solve the above technical problems, the present application provides the following technical solutions:

[0006] In a first aspect, the present application provides a performance analysis method for SQL statements, comprising:

[0007] According to the characteristic attributes of the source code to be analyzed, the source code to be analyzed is parsed to obtain corresponding SQL statements to be analyzed; the characteristic attributes at least include table data volume, statement quantity and index parameter;

[0008] According to the characteristic attributes, the performance analysis parameters of the SQL statements to be analyzed are determined; the performance analysis parameters include static analysis parameters and dynamic analysis parameters;

[0009] The static analysis parameters and the dynamic analysis parameters are input into a pre-constructed SQL statement performance analysis model to obtain corresponding performance analysis results.

[0010] Further, the parsing of the to-be-analyzed source code according to the characteristic attribute of the to-be-analyzed source code obtains a corresponding to-be-analyzed SQL statement, and the method further comprises:

[0011] According to the characteristic attribute of the to-be-analyzed source code, a corresponding syntax tree is generated.

[0012] According to the keyword in the syntax tree, the to-be-analyzed SQL statement is determined.

[0013] Further, the static analysis parameters comprise a table data amount average value, a table performance attention degree, a SQL statement complexity, and a SQL statement index matching degree; and the performance analysis parameters of the to-be-analyzed SQL statement determined according to the characteristic attribute comprise:

[0014] The table data amount average value is calculated according to the table data amount.

[0015] The SQL statement complexity is calculated according to the statement quantity.

[0016] The SQL statement index matching degree is calculated according to the index parameter.

[0017] Further, the performance analysis parameters comprise the dynamic analysis parameters; the dynamic analysis parameters comprise an effective execution time and a historical execution detail ratio; and the performance analysis parameters of the to-be-analyzed SQL statement determined according to the characteristic attribute comprise:

[0018] Dynamic execution information of the to-be-analyzed SQL statement is obtained from a historical database; the dynamic execution information at least comprises an execution total time consumption, a calculation processing time consumption, an input / output time consumption, and a lock waiting time consumption.

[0019] Full table scanning, full partition scanning, index fast full scanning, and index jump scanning are performed on the to-be-analyzed SQL statement to obtain the effective execution time and the historical execution detail ratio.

[0020] Further, the step of constructing the SQL statement performance analysis model comprises:

[0021] A static characteristic parameter is calculated according to the static analysis parameters and corresponding static analysis weights.

[0022] A dynamic characteristic parameter is calculated according to the dynamic analysis parameters and corresponding dynamic analysis weights.

[0023] The static characteristic parameter and the dynamic characteristic parameter are respectively input into a neural network regression model to obtain a static analysis model and a dynamic analysis model.

[0024] combine the static analysis model and the dynamic analysis model to obtain the SQL statement performance analysis model.

[0025] Further, the inputting the static analysis parameter and the dynamic analysis parameter into the pre-constructed SQL statement performance analysis model to obtain the corresponding performance analysis result comprises:

[0026] calculating a static characteristic parameter according to the static analysis parameter and the corresponding static analysis weight;

[0027] calculating a dynamic characteristic parameter according to the dynamic analysis parameter and the corresponding dynamic analysis weight;

[0028] inputting the static characteristic parameter and the dynamic characteristic parameter into the SQL statement performance analysis model to obtain the corresponding performance analysis result.

[0029] Further, the performance analysis result comprises a static analysis result and a dynamic analysis result; after the inputting the static analysis parameter and the dynamic analysis parameter into the pre-constructed SQL statement performance analysis model to obtain the corresponding performance analysis result, the method further comprises:

[0030] comparing a preset static performance analysis threshold with the static analysis result to obtain a first comparison result;

[0031] comparing a preset dynamic performance analysis threshold with the dynamic analysis result to obtain a second comparison result;

[0032] when the first comparison result and the second comparison result are both passed, determining that the performance of the to-be-analyzed SQL statement is up to standard.

[0033] In a second aspect, the present application provides a SQL statement performance analysis device, comprising:

[0034] a SQL statement extraction unit configured to parse a to-be-analyzed source code according to a characteristic attribute of the to-be-analyzed source code to obtain a corresponding to-be-analyzed SQL statement; the characteristic attribute at least comprises table data volume, statement quantity and index parameter;

[0035] an analysis parameter determination unit configured to determine a performance analysis parameter of the to-be-analyzed SQL statement according to the characteristic attribute; the performance analysis parameter comprises a static analysis parameter and a dynamic analysis parameter;

[0036] a performance analysis unit configured to input the static analysis parameter and the dynamic analysis parameter into a pre-constructed SQL statement performance analysis model to obtain a corresponding performance analysis result.

[0037] Further, the SQL statement extraction unit comprises a syntax tree generation module and a SQL statement analysis module.

[0038] The syntax tree generation module is configured to generate a corresponding syntax tree according to the characteristic attribute of the source code to be analyzed.

[0039] The SQL statement analysis module is configured to determine the SQL statement to be analyzed according to a keyword in the syntax tree.

[0040] Further, the static analysis parameters comprise a table data volume average value, a table performance attention degree, a SQL statement complexity, and a SQL statement index matching degree; and the analysis parameter determination unit comprises:

[0041] The table data volume average value calculation module is configured to calculate the table data volume average value according to the table data volume.

[0042] The SQL statement complexity calculation module is configured to calculate the SQL statement complexity according to the statement quantity.

[0043] The SQL statement index matching degree calculation module is configured to calculate the SQL statement index matching degree according to the index parameter.

[0044] Further, the dynamic analysis parameters comprise an effective execution time and a historical execution detail ratio; and the analysis parameter determination unit comprises a dynamic execution information acquisition module and an execution time ratio calculation module.

[0045] The dynamic execution information acquisition module is configured to acquire dynamic execution information of the SQL statement to be analyzed from a historical database; and the dynamic execution information at least comprises an execution total time consumption, a calculation processing time consumption, an input / output time consumption, and a lock waiting time consumption.

[0046] The execution time ratio calculation module is configured to perform full table scanning, full partition scanning, index fast full scanning, and index jump scanning on the SQL statement to be analyzed, so as to obtain the effective execution time and the historical execution detail ratio.

[0047] Further, the SQL statement performance analysis device further comprises a static parameter calculation unit, a dynamic parameter calculation unit, a model training unit, and a model combination unit.

[0048] The static parameter calculation unit is configured to calculate a static characteristic parameter according to the static analysis parameter and a corresponding static analysis weight.

[0049] The dynamic parameter calculation unit is configured to calculate a dynamic characteristic parameter according to the dynamic analysis parameter and a corresponding dynamic analysis weight.

[0050] a model training unit, configured to input the static feature parameter and the dynamic feature parameter into a neural network regression model respectively to obtain a static analysis model and a dynamic analysis model;

[0051] a model combination unit, configured to combine the static analysis model and the dynamic analysis model to obtain the SQL statement performance analysis model.

[0052] Further, the performance analysis result includes a static analysis result and a dynamic analysis result; the SQL statement performance analysis apparatus further includes a first result determination unit, a second result determination unit and a performance judgment unit.

[0053] the first result determination unit is configured to compare a preset static performance analysis threshold with the static analysis result to obtain a first comparison result;

[0054] the second result determination unit is configured to compare a preset dynamic performance analysis threshold with the dynamic analysis result to obtain a second comparison result;

[0055] the performance judgment unit is configured to determine that the performance of the SQL statement to be analyzed is up to standard when the first comparison result and the second comparison result are both passed.

[0056] In a third aspect, the present application provides an electronic device including a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the SQL statement performance analysis method.

[0057] In a fourth aspect, the present application provides a computer readable storage medium having a computer program stored thereon, wherein the computer program is executable by a processor to implement the steps of the SQL statement performance analysis method.

[0058] In a fifth aspect, the present application provides a computer program product including a computer program / instruction, wherein the computer program / instruction is executable by a processor to implement the steps of the SQL statement performance analysis method.

[0059] To solve the problems in the prior art, the SQL statement performance analysis method and apparatus provided by the present application can analyze the performance of the SQL statement in the source code to be analyzed by combining static and dynamic analysis, effectively improving the efficiency of writing and optimizing the SQL statement in the rapid iteration process of software development, and improving the intelligent analysis capability of the performance of the SQL statement in the software product development process. BRIEF DESCRIPTION OF DRAWINGS

[0060] In order to make the technical solutions in the embodiments of the present application or the prior art clearer, the accompanying drawings needed in the embodiments or prior art description will be briefly introduced. Obviously, the accompanying drawings in the following description only only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained from these drawings without creative labor.

[0061] Figure 1 One of the flowcharts of the SQL statement performance analysis method in the embodiments of the present application;

[0062] Figure 2 The flowchart of obtaining the SQL statement to be analyzed in the embodiments of the present application;

[0063] Figure 3 The flowchart of determining the static performance analysis parameter in the embodiments of the present application;

[0064] Figure 4 The flowchart of determining the dynamic performance analysis parameter in the embodiments of the present application;

[0065] Figure 5 The flowchart of constructing the SQL statement performance analysis model in the embodiments of the present application;

[0066] Figure 6 The second flowchart of the SQL statement performance analysis method in the embodiments of the present application;

[0067] Figure 7 One of the structural diagrams of the SQL statement performance analysis method device in the embodiments of the present application;

[0068] Figure 8 The structural diagram of the SQL statement extraction unit in the embodiments of the present application;

[0069] Figure 9 The structural diagram of the analysis parameter determination unit in the embodiments of the present application;

[0070] Figure 10 The structural diagram of the analysis parameter determination unit in the embodiments of the present application;

[0071] Figure 11 The second structural diagram of the SQL statement performance analysis method device in the embodiments of the present application;

[0072] Figure 12 The third structural diagram of the SQL statement performance analysis method device in the embodiments of the present application;

[0073] Figure 13 The structural schematic diagram of the electronic device in the embodiments of the present application;

[0074] Figure 14A flowchart for obtaining the performance analysis result in the embodiments of the present application. DETAILED DESCRIPTION

[0075] The technical solutions in the embodiments of the present application will be clearly and completely described in connection with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all the other embodiments obtained by a person of ordinary skill in the art without creative work are within the scope of protection of the present application.

[0076] It should be noted that the performance analysis method and device of the SQL statement provided in the present application can be used in the financial field, and can also be used in any field other than the financial field. The application field of the performance analysis method and device of the SQL statement provided in the present application is not limited.

[0077] In the technical solutions of the present application, the acquisition, storage, use and processing of data all comply with the relevant provisions of the national laws and regulations.

[0078] In an embodiment, referring to Figure 1 In order to perform performance analysis on the SQL statement in the source code to be analyzed by combining static and dynamic methods, the present application provides a performance analysis method of a SQL statement, comprising:

[0079] S101: parsing the source code to be analyzed according to the characteristic attributes of the source code to be analyzed to obtain the corresponding SQL statement to be analyzed; the characteristic attributes at least include table data volume, statement quantity and index parameter;

[0080] It can be understood that, with the continuous improvement of people's demand for software application, the period from the demand for software version to the development and delivery is getting shorter and shorter. As an important part of checking code quality, static code scanning can quickly locate potential errors in the code before the project coding is submitted, find inferior code, and propose corresponding code optimization suggestions.

[0081] However, the existing static code scanning tool has at least the following problems when analyzing the static parameters of the SQL statement in the source code: first, the existing static code scanning tool focuses on analyzing the syntax of the SQL statement. When analyzing, the corresponding check rule is formed according to the writing specification of the SQL statement. To some extent, the check rule is relatively stereotyped and difficult to adapt to various actual business needs, causing false positives. Second, the existing static code scanning tool does not run the corresponding code in the actual database environment when checking the SQL statement, causing certain checking errors. Third, the existing static code scanning tool does not check the real execution effect of the SQL statement in the dynamic execution process, and does not intelligently analyze the running efficiency of the SQL statement combined with the actual data distribution and data volume, resulting in that the efficiency check can only be performed manually. In summary, when checking the SQL statement, the existing static code scanning tool has a long troubleshooting process and a long cycle, which reduces the efficiency of the continuous integration process and affects software delivery.

[0082] In order to solve the problems in the prior art, the present application provides a performance analysis method of a SQL statement, which improves the checking accuracy of the performance analysis of the SQL statement at delivery.

[0083] The specific implementation of step S101 can be:

[0084] In an embodiment, referring to Figure 2 , the parsing of the to-be-analyzed source code according to the characteristic attribute of the to-be-analyzed source code to obtain the corresponding to-be-analyzed SQL statement comprises:

[0085] S201: generating a corresponding syntax tree according to the characteristic attribute of the to-be-analyzed source code; wherein the characteristic attribute includes but is not limited to a syntax rule;

[0086] S202: determining the to-be-analyzed SQL statement according to the keywords in the syntax tree.

[0087] Specifically, first, obtain the software product attribute configuration (also referred to as characteristic attribute); the attribute can be obtained by using GIT, JENKINS and the like.

[0088] Second, obtain the source code of the software product; the source code can be downloaded by using GIT, JENKINS and the like.

[0089] Third, scan the source code of the software product, parse the SQL statement, and record the online or batch label of the SQL according to the source code; obtain the marked SQL table data volume; generate an abstract syntax tree of the SQL.

[0090] Among them, the online transaction algorithm is real-time return, the response to the actual requirement is relatively high, and the concurrency may be relatively large; the batch can be understood as a timing execution job process, and the response requirement is relatively low.

[0091] The specific implementation is as follows:

[0092] 1. Download product attribute configuration, including but not limited to source code online batch label information, key table label information, table data volume average, table data distribution, table structure information, table constraint information and table index information.

[0093] 2. Download product software source code

[0094] 3. Scanning analysis is performed on the source code of the code library according to preset scanning rules (setting check rules, scanning and analyzing the program directory, checking java source files and xml files respectively; the java syntax tree is parsed according to the following code analysis to parse out the target SQL statements to be analyzed.

[0095] Implementation mode one: the java rule analysis sample java class can be parsed to form a syntax tree, and the SQL statements introduced by traversing the syntax tree are annotated. (As shown in Table 1)

[0096] Table 1

[0097]

[0098]

[0099] Implementation mode two: the code can traverse the xml file configuration sql to parse out the SQL statements configured by the xml. (As shown in Table 2)

[0100] Table 2

[0101]

[0102]

[0103] The SQL statements are subjected to syntax analysis to generate the abstract syntax tree of the SQL statements.

[0104] For example, the SQL statements parsed above are as follows:

[0105] SELECT ZONENO,PRTOEX,PRODID,CURRTYPE FROM ATHFPSUB WHERE ZONENO=#{zoneNo} AND OPENBRNO=#{openBrno}.

[0106] Among them, the SQL syntax tree is shown in Table 3.

[0107] Table 3

[0108]

[0109]

[0110] S102: determining performance analysis parameters of the SQL statement to be analyzed according to the characteristic attribute; the performance analysis parameters include static analysis parameters and dynamic analysis parameters;

[0111] It can be understood that the specific implementation of determining the static analysis parameters in step S102 can refer to steps S301 to S303.

[0112] In an embodiment, referring to Figure 3 This embodiment is an embodiment of analyzing static parameters. The static analysis parameters include: table data amount average, table performance attention degree, SQL statement complexity and SQL statement index matching degree; the performance analysis parameters of the SQL statement to be analyzed are determined according to the characteristic attribute, including:

[0113] S301: calculating the table data amount average according to the table data amount;

[0114] Specifically, the table data amount size involved in the SQL statement is obtained from historical database information statistics, and the table data amount average is calculated according to the table data amount. Through a monitoring system, the data amount of the table is obtained by monitoring the production database information officially providing services. For example, for an ORACLE database, the data amount of the table can be obtained by using the table analysis statement analyze tables, and can also be obtained by querying user_tables; for example, for a MYSQL database, the data amount of the table can be obtained by querying information_schema.tables.

[0115] S302: calculating the table performance attention degree according to the table data amount;

[0116] Specifically, the transaction calling amount of the table involved in the target SQL is obtained from historical database statistics, and the table performance attention degree is calculated according to the table transaction amount. Through code implementation of the mybatis plug-in interception function, the SQL situation of the transaction calling is obtained, and the calling transaction amount of the table is obtained according to the intercepted SQL statement statistics. The table with larger calling amount has higher performance attention degree.

[0117] S303: calculating the SQL statement complexity according to the statement quantity;

[0118] Specifically, the complexity of the target SQL statement is analyzed by analyzing the syntax keywords of the target SQL statement, such as "JOIN, HAVING, GROUP BY, UNION, ORDER BY, DISTINCT, database function", and the number of keywords. The SQL statement is parsed, and the number of keywords is obtained and counted. For example, when the number of keywords is less than or equal to 3, the complexity is 10; when the number of keywords is greater than or equal to 4 and less than or equal to 8, the complexity is 15; when the number of keywords is greater than 7 and less than 15, the complexity is 20; and when the number of keywords is greater than 15, the complexity is 30.

[0119] S304: Calculate the index matching degree of the SQL statement according to the index parameter.

[0120] Specifically, the constraints and indexes of the target SQL involved table are obtained from the historical database statistics information, the data amount of the historical table index column is obtained, and the index matching degree of the target SQL is obtained by analyzing the relationship between the target SQL query condition column and the index configuration. Through the monitoring system, the production database information officially providing services is monitored, the data amount and the deduplicated data amount of each index column of the data table are counted, and the hit of the index column corresponding to the WHERE clause condition column in the target SQL statement is analyzed. The index matching degree of the target SQL is analyzed by the ratio of the corresponding deduplicated data amount to the column data amount of each index column of the SQL.

[0121] In an embodiment, the specification checking result can be generated according to the generated SQL abstract syntax tree, including full table scan, SQL statement index matching degree, complexity checking, and coding checking error.

[0122] Referring to Table 4, according to the SQL statement: SELECT ZONENO, PRTOEX, PRODID, CURRTYPE FROM ATHFPSUB WHERE ZONENO = #{zoneNo} AND OPENBRNO = #{openBrno}. The following rules are checked, and the results are checked out:

[0123] Table 4

[0124]

[0125]

[0126] It can be understood that the specific implementation of determining the dynamic analysis parameter in step S102 can refer to steps S401 to S402.

[0127] In an embodiment, referring to Figure 4, the performance analysis parameter of the SQL statement to be analyzed is determined according to the feature attribute, including:

[0128] S401: Obtain dynamic execution information of the SQL statement to be analyzed from a historical database; the dynamic execution information at least includes total execution time, calculation processing time, input / output time and lock waiting time;

[0129] Specifically, by analyzing the historical SQL execution, the target SQL to be analyzed is executed multiple times in a test environment database, the results of the multiple execution are analyzed, the database slow log is monitored, and the execution time, the calculation processing time, the input / output time, the lock waiting time and the like of the SQL are obtained. The execution of the SQL is queried back through the corresponding function of the database software, for example, the execution of the SQL is queried back through v$sqlarea, v$sql_plan, v$sql and the like of the oracle database; the target SQL is analyzed by combining the explain command, and finally the dynamic execution of the target SQL, that is, the total execution time, the calculation processing time, the input / output time and the lock waiting time are obtained.

[0130] S402: Perform full table scan, full partition scan, index fast full scan and index jump scan on the SQL statement to be analyzed, and obtain the effective execution time and the historical execution detail ratio.

[0131] By analyzing the historical SQL execution and performing multiple dynamic executions of the target SQL, the execution of the SQL is analyzed, the matching of the index is obtained, and specifically, the full table scan, the full partition scan, the index fast full scan and the index jump scan are obtained. In this step, the SQL to be analyzed is executed multiple times in the test database and analyzed, the corresponding execution condition index data is obtained, and then the performance evaluation model is input for calculation and analysis.

[0132] 1. The SQL with performance problem is introduced, the database information, the table structure and the table data are assembled, the production table data volume and the data volume distribution are obtained.

[0133] 2. The SQL is executed as a SQL client, and the slow log of the SQL execution is checked.

[0134] 3. Through the database, monitoring and obtaining: SQL total time consumption, CPU usage, IO read and write, lock waiting time consumption, execution plan analysis: full table scan, full partition scan, Cartesian product, index fast full scan, index jump scan, Cost cost overhead, etc. Dynamic execution analysis: SQL effective execution time analysis, historical execution detail ratio, query intermediate result set too large, etc.

[0135] S103: input the static analysis parameters and dynamic analysis parameters into the pre-constructed SQL statement performance analysis model to obtain the corresponding performance analysis result.

[0136] It should be noted that in an embodiment, referring to Figure 5 , the step of constructing the SQL statement performance analysis model comprises:

[0137] S501: calculate the historical static feature parameters according to the historical static analysis parameters and the corresponding static analysis weights;

[0138] S502: calculate the historical dynamic feature parameters according to the historical dynamic analysis parameters and the corresponding dynamic analysis weights;

[0139] S503: input the historical static feature parameters and the historical dynamic feature parameters into the neural network regression model respectively to obtain the static analysis model and the dynamic analysis model;

[0140] S504: combine the static analysis model and the dynamic analysis model to obtain the SQL statement performance analysis model.

[0141] It can be understood that the logistic regression algorithm of the neural network (also referred to as the neural network regression model) is: g(x) is an index of whether there is a performance problem.

[0142] For the static analysis model and the dynamic analysis model, the training is all inputting the corresponding analysis parameters into the above neural network regression model to obtain; the difference is only that when the analysis parameters are the static feature parameters, the static analysis model is obtained; when the analysis parameters are the dynamic feature parameters, the dynamic analysis model is obtained.

[0143] The static analysis model is described below (the input parameters below are historical static analysis parameters):

[0144] Wherein, x=(r1xp1+r2xp2+r3xp3+r4xp4+r5xp5+r6xp6-t) is calculated by the formula; r1, r2, r3, r4, r5, r6 correspond to SQL batch online label (0 batch, 1 online), table data volume average, full table scan, SQL statement index matching degree, SQL complexity, SQL specification analysis result respectively; p1, p2, p3, p4, p5, p6 correspond to SQL batch online label, table data volume average weight, full table scan weight, static check result, complexity weight, SQL specification analysis result respectively, and t is a threshold value.

[0145] Wherein, the pre-set SQL statement performance problem situation is recorded, the SQL batch online label, the table data volume average, the full table scan, the SQL statement index matching degree and the complexity specific value are introduced; and the SQL performance problem reference value calculated by the logistic regression algorithm is used, and the two are taken as a group of data; the calculation model is operated to obtain the weight value and the threshold value; then at least two groups of data are prepared, the model is verified, and the weight value and the threshold value are adjusted until the requirements are met.

[0146] In step S103, the static intelligent analysis process is as follows:

[0147] In an embodiment, referring to Figure 14 , the static analysis parameters and the dynamic analysis parameters are input into the pre-constructed SQL statement performance analysis model to obtain the corresponding performance analysis results, including:

[0148] S501': calculating a static feature parameter according to the static analysis parameters and the corresponding static analysis weight;

[0149] S502': calculating a dynamic feature parameter according to the dynamic analysis parameters and the corresponding dynamic analysis weight;

[0150] S503': inputting the static feature parameter and the dynamic feature parameter into the SQL statement performance analysis model respectively to obtain the corresponding performance analysis results.

[0151] Specifically, the static feature parameter is input into the static analysis model in the SQL statement performance analysis model; and the dynamic feature parameter is input into the dynamic analysis model in the SQL statement performance analysis model.

[0152] According to the given SQL static scanning result, the logistic regression algorithm of the neural network is used for calculation to determine whether the SQL statement has a performance problem.

[0153] The logistic regression algorithm of the neural network: g(x) represents whether there is a performance problem.

[0154] Wherein x=(r1xp1+r2xp2+r3xp3+r4xp4+r5xp5+r6xp6-t) is calculated by the formula; r1, r2, r3, r4, r5, r6 correspond to SQL batch online label, table data volume average, key table label, SQL statement index matching degree, SQL statement complexity, specification matching degree respectively; p1, p2, p3, p4, p5, p6 correspond to SQL batch online label, table data volume average weight, key table label, SQL statement index matching degree weight, SQL statement complexity weight, specification matching degree respectively, and t is a threshold value.

[0155] Wherein, the pre-set SQL statement performance problem situation is recorded, and the specific values of SQL batch online label, table data volume average, key table label, SQL statement index matching degree, SQL statement complexity are recorded; and the SQL performance problem reference value calculated by the logistic regression algorithm is used, and the two are taken as a group of data; the calculation model is operated to obtain the weight value and the threshold value; then at least two groups of data are prepared, the model is verified, and the weight value and the threshold value are adjusted until the requirements are met.

[0156] In step S103, the dynamic intelligent analysis process is as follows:

[0157] The database statement processes SQL statements, introduces database information, table structure and table data assembly; executes SQL as a SQL client, and checks SQL execution logs to analyze total execution time, lock waiting time, hit row number and search row number of the statements. (See Table 5)

[0158] Table 5

[0159]

[0160] Through the database, SQL execution information such as total execution time, CPU usage, IO read and write, lock waiting time, execution plan analysis: full table scan, full partition scan, Cartesian product, index fast full scan, index jump scan, Cost cost overhead, etc. Dynamic execution analysis: SQL effective execution time analysis, historical execution detail ratio, query intermediate result set too large, etc. According to the performance analysis model, each index of SQL monitoring is calculated to determine whether there is a performance problem.

[0161] The logistic regression algorithm of the neural network is: g(x) represents whether there is a performance problem.

[0162] Wherein, x=(r1'xp1'+r2'xp2'+r3'xp3'+r4'xp4'+r5'xp5'-t) is calculated by the formula; r1', r2', r3', r4', r5' correspond to SQL execution total time consumption, CPU usage, IO read-write, lock waiting time consumption, execution plan analysis respectively; p1', p2', p3', p4', p5' correspond to SQL execution total time consumption weight, CPU usage weight, IO read-write weight, lock waiting time consumption weight, execution plan analysis weight respectively, and t is a threshold value.

[0163] Wherein, the pre-set SQL statement performance problem situation and the SQL execution total time consumption, CPU usage, IO read-write, lock waiting time consumption, execution plan analysis are recorded; and the SQL performance problem reference value calculated by the logistic regression algorithm is used as a group of data; the calculation model is operated to obtain the weight value and the threshold value; and at least two groups of data are prepared to verify the model and adjust the weight value and the threshold value until the requirements are met.

[0164] In an embodiment, referring to Figure 6 The performance analysis result includes: static analysis result and dynamic analysis result; after the static analysis parameter and the dynamic analysis parameter are input into the pre-constructed SQL statement performance analysis model to obtain the corresponding performance analysis result, the performance analysis result further includes:

[0165] S601: compare the preset static performance analysis threshold value with the static analysis result to obtain a first comparison result; as shown in the following table example data: the larger the table data volume, the greater the performance impact; the more the table attention, the greater the call volume, the higher the performance risk; the greater the index matching degree value, the higher the matching degree; the greater the SQL complexity, the greater the impact on system performance; the more the SQL specification analysis hit problems, the greater the performance risk. By selecting sample data and cleaning, the static analysis sample of SQL is obtained. According to the logistic regression algorithm model of neural network: Wherein, the threshold value is set to 0.5, the model parameters are obtained by iterative calculation and training. The model is applied to each test SQL to give a score of 0 to 1; the greater the score, the greater the possibility of SQL static performance risk.(See Table 6 and Table 7.)

[0166] Table 6 training example

[0167]

[0168] Table 7 matching result

[0169] Threshold Predictive power (0,0.5) Poor effect 0.5 Threshold (0.5,0.7] Low effect (0.7,0.85] Moderate effect (0.85,0.95] Excellent effect (0.95,1] Focus on data validity

[0170] S602: Compare the preset dynamic performance analysis threshold with the dynamic analysis result to obtain a second comparison result; as shown in the following table example data: the longer the SQL execution time, the greater the performance impact; the higher the CPU usage, the greater the resource consumption, and the higher the performance risk; the more IO read and write, the greater the performance consumption; the longer the lock waiting, the worse the execution efficiency; the more execution analysis data scanning, the higher the performance risk. By selecting sample data and cleaning, a dynamic execution analysis sample of SQL is obtained. According to the logistic regression algorithm model of the neural network: Wherein the threshold is set to 0.5, and the model calculation is obtained. The model parameters are obtained by iterative calculation and training of the sample. The model is applied to each test SQL to give a score of 0 to 1; the greater the score, the greater the possibility of SQL dynamic performance risk. (See Tables 8 and 9.)

[0171] Table 8 Training example

[0172]

[0173]

[0174] Table 9 Matching result

[0175] Threshold Predictive power (0,0.5) Poor effect 0.5 Threshold (0.5,0.7] Low effect (0.7,0.85] Moderate effect (0.85,0.95] Excellent effect (0.95,1] Focus on data validity

[0176] S603: When the first comparison result and the second comparison result are both passed, it is determined that the performance of the SQL statement to be analyzed meets the standard.

[0177] It can be understood that in the embodiments of the present application, any result that does not meet the standard will be reported as an error.

[0178] From the above description, it can be seen that the performance analysis method and device of the SQL statement provided by the present application can analyze the performance of the SQL statement in the source code to be analyzed by combining static and dynamic methods, effectively improving the writing and optimization efficiency of the SQL statement in the rapid iteration process of software development, and improving the intelligent analysis ability of the performance of the SQL statement in the software product development process.

[0179] Therefore, on the basis of static code scanning, the intelligent static analysis of SQL statements is improved, and the combination of intelligent analysis of SQL dynamic execution results is improved. At present, dynamic running monitoring of SQL running efficiency is mainly accurate in the software production running stage, which leads to late discovery of efficiency problems.

[0180] Based on the same inventive concept, the embodiment of the present application further provides a performance analysis method and device of SQL statement, which can be used to implement the method described in the above embodiment, as described in the following embodiment. Since the principle of the performance analysis method of SQL statement solves the problem similarly, the implementation of the performance analysis method of SQL statement can refer to the implementation of the method of determining software performance benchmark, and the repeated parts will not be described here. The term "unit" or "module" used below can be a combination of software and / or hardware that implements a predetermined function. Although the system described in the following embodiment is preferably implemented in software, hardware, or a combination of software and hardware is also possible and is conceived.

[0181] In an embodiment, referring to Figure 7 In order to be able to analyze the performance of the SQL statement in the source code to be analyzed by combining static and dynamic, the present application provides a performance analysis device of SQL statement, comprising:

[0182] The SQL statement extraction unit 701 is configured to parse the source code to be analyzed according to the characteristic attribute of the source code to be analyzed, and obtain the corresponding SQL statement to be analyzed; the characteristic attribute at least includes table data volume, statement quantity and index parameter;

[0183] The analysis parameter determination unit 702 is configured to determine the performance analysis parameter of the SQL statement to be analyzed according to the characteristic attribute; the performance analysis parameter includes static analysis parameter and dynamic analysis parameter;

[0184] The performance analysis unit 703 is configured to input the static analysis parameter and the dynamic analysis parameter into the pre-constructed SQL statement performance analysis model, and obtain the corresponding performance analysis result.

[0185] In an embodiment, referring to Figure 8 The SQL statement extraction unit 701 comprises a syntax tree generation module 801 and a SQL statement analysis module 802.

[0186] The syntax tree generation module 801 is configured to generate the corresponding syntax tree according to the characteristic attribute of the source code to be analyzed;

[0187] The SQL statement analysis module 802 is configured to determine the SQL statement to be analyzed according to the keyword in the syntax tree.

[0188] In an embodiment, referring to Figure 9 The static analysis parameter includes table data volume average, table performance attention degree, SQL statement complexity and SQL statement index matching degree; the analysis parameter determination unit 702 comprises:

[0189] The table data amount average value calculation module 901 is configured to calculate the table data amount average value according to the table data amount.

[0190] The SQL statement complexity calculation module 902 is configured to calculate the SQL statement complexity according to the statement quantity.

[0191] The SQL statement index matching degree calculation module 903 is configured to calculate the SQL statement index matching degree according to the index parameter.

[0192] In an embodiment, referring to Figure 10 The dynamic analysis parameter includes effective execution time and historical execution detail ratio, and the analysis parameter determination unit 702 includes a dynamic execution information acquisition module 1001 and an execution time ratio calculation module 1002.

[0193] The dynamic execution information acquisition module 1001 is configured to acquire dynamic execution information of the SQL statement to be analyzed from a historical database, and the dynamic execution information at least includes total execution time, calculation processing time, input / output time and lock waiting time.

[0194] The execution time ratio calculation module 1002 is configured to perform full table scanning, full partition scanning, index fast full scanning and index jump scanning on the SQL statement to be analyzed according to the dynamic execution information acquisition module 1001, so as to obtain the effective execution time and the historical execution detail ratio.

[0195] In an embodiment, referring to Figure 11 The SQL statement performance analysis device further includes a static parameter calculation unit 1101, a dynamic parameter calculation unit 1102, a model training unit 1103 and a model combination unit 1104.

[0196] The static parameter calculation unit 1101 is configured to calculate a static feature parameter according to the static analysis parameter and a corresponding static analysis weight.

[0197] The dynamic parameter calculation unit 1102 is configured to calculate a dynamic feature parameter according to the dynamic analysis parameter and a corresponding dynamic analysis weight.

[0198] The model training unit 1103 is configured to input the static feature parameter and the dynamic feature parameter into a neural network regression model respectively, so as to obtain a static analysis model and a dynamic analysis model.

[0199] The model combination unit 1104 is configured to combine the static analysis model and the dynamic analysis model, so as to obtain the SQL statement performance analysis model.

[0200] In an embodiment, referring to Figure 12The performance analysis result includes a static analysis result and a dynamic analysis result. The performance analysis device of the SQL statement further includes a first result determining unit 1201, a second result determining unit 1202, and a performance judging unit 1203.

[0201] The first result determining unit 1201 is configured to compare a preset static performance analysis threshold with the static analysis result to obtain a first comparison result.

[0202] The second result determining unit 1202 is configured to compare a preset dynamic performance analysis threshold with the dynamic analysis result to obtain a second comparison result.

[0203] The performance judging unit 1203 is configured to determine that the performance of the SQL statement to be analyzed is up to standard when the first comparison result and the second comparison result are both passed.

[0204] From the hardware level, in order to analyze the performance of the SQL statement in the source code to be analyzed by combining static and dynamic analysis, the present application provides an embodiment of an electronic device for implementing all or part of the performance analysis method of the SQL statement, which specifically includes the following content:

[0205] A processor (Processor), a memory (Memory), a communications interface (Communications Interface), and a bus; wherein the processor, the memory, and the communications interface communicate with each other through the bus; the communications interface is configured to implement information transmission between the performance analysis method device of the SQL statement and a core business system, a user terminal, and a related database and other related devices; the logic controller can be a desktop computer, a tablet computer, a mobile terminal, and the like, and the present embodiment is not limited thereto. In the present embodiment, the logic controller can be implemented by referring to the embodiments of the performance analysis method of the SQL statement and the embodiments of the performance analysis method device of the SQL statement, the contents of which are incorporated herein, and repeated descriptions are omitted.

[0206] It can be understood that the user terminal can include a smart phone, a tablet electronic device, a network set-top box, a portable computer, a desktop computer, a personal digital assistant (PDA), a vehicle-mounted device, a smart wearable device, and the like. The smart wearable device can include smart glasses, a smart watch, a smart bracelet, and the like.

[0207] In actual application, part of the SQL statement performance analysis method can be executed on the electronic device side as described above, or all operations can be completed in the client device. Specifically, the selection can be made according to the processing capacity of the client device and the limitation of the user use scenario, etc. The present application does not limit this. If all operations are completed in the client device, the client device can further include a processor.

[0208] The client device described above can have a communication module (i.e., a communication unit) and can be communicatively connected with a remote server to realize data transmission with the server. The server can include a server on the task scheduling center side, and can also include a server of an intermediate platform in other implementation scenarios, such as a server of a third-party server platform communicatively connected with the task scheduling center server. The server can include a single computer device, or a server cluster composed of multiple servers, or a server structure of a distributed device.

[0209] Figure 13 A schematic block diagram of a system configuration of the electronic device 9600 of an embodiment of the present application is shown in FIG. 9. As shown in the figure, the electronic device 9600 can include a central processor 9100 and a memory 9140; the memory 9140 is coupled to the central processor 9100. It is worth noting that the structure shown in the figure is exemplary; other types of structures can also be used to supplement or replace the structure to realize telecommunication functions or other functions. Figure 13 Figure 13 The structure shown in the figure is exemplary; other types of structures can also be used to supplement or replace the structure to realize telecommunication functions or other functions.

[0210] In an embodiment, the SQL statement performance analysis method function can be integrated into the central processor 9100. The central processor 9100 can be configured to perform the following control:

[0211] S101: parsing the to-be-analyzed source code according to a characteristic attribute of the to-be-analyzed source code to obtain a corresponding to-be-analyzed SQL statement; the characteristic attribute at least includes table data volume, statement quantity, and index parameter;

[0212] S102: determining a performance analysis parameter of the to-be-analyzed SQL statement according to the characteristic attribute; the performance analysis parameter includes a static analysis parameter and a dynamic analysis parameter;

[0213] S103: inputting the static analysis parameter and the dynamic analysis parameter into a pre-constructed SQL statement performance analysis model to obtain a corresponding performance analysis result.

[0214] ​From the above description, the SQL statement performance analysis method and device provided by the application can perform performance analysis on the SQL statements in the source code to be analyzed by combining static and dynamic methods, effectively improving the writing and optimization efficiency of the SQL statements in the rapid iteration process of software development, and improving the intelligent analysis capability of the SQL statement performance in the software product development process.

[0215] In another embodiment, the SQL statement performance analysis method and device can be configured separately from the central processor 9100, for example, the data composite transmission device SQL statement performance analysis method and device can be configured as a chip connected with the central processor 9100, and the function of the SQL statement performance analysis method is realized through the control of the central processor.

[0216] As shown in Figure 13 , the electronic device 9600 can also include a communication module 9110, an input unit 9120, an audio processor 9130, a display 9160, and a power supply 9170. It should be noted that the electronic device 9600 does not necessarily include all the components shown in Figure 13 ; in addition, the electronic device 9600 can also include components not shown in Figure 13 , which can be referred to the prior art.

[0217] As shown in Figure 13 , the central processor 9100, also known as a controller or an operation control, can include a microprocessor or other processor device and / or a logic device, which receives input and controls the operation of each component of the electronic device 9600.

[0218] The memory 9140, for example, can be one or more of a buffer, a flash memory, a hard drive, a removable media, a volatile memory, a non-volatile memory, or other suitable device. The above information related to failure can be stored, and programs related to the information can also be stored. The central processor 9100 can execute the programs stored in the memory 9140 to realize information storage or processing, etc.

[0219] The input unit 9120 provides input to the central processor 9100. The input unit 9120 is, for example, a key or a touch input device. The power supply 9170 is used to provide power to the electronic device 9600. The display 9160 is used to display display objects such as images and text. The display can be, for example, an LCD display, but is not limited thereto.

[0220] The memory 9140 can be a solid state memory such as a read only memory (ROM), a random access memory (RAM), a SIM card, or the like. It can also be a memory that retains information even when power is off, can be selectively erased, and is provided with more data, an example of which is sometimes referred to as an EPROM or the like. The memory 9140 can also be some other type of device. The memory 9140 includes a buffer memory 9141 (sometimes referred to as a buffer). The memory 9140 can include an application / function storage 9142 for storing application programs and function programs or for storing a flow for executing an operation of the electronic device 9600 by the central processing unit 9100.

[0221] The memory 9140 can also include a data storage 9143 for storing data such as contacts, digital data, pictures, sounds, and / or any other data used by the electronic device. A driver storage 9144 of the memory 9140 can include various drivers of the electronic device for a communication function and / or for performing other functions of the electronic device such as a messaging application, a phonebook application, and the like.

[0222] The communication module 9110 is a transmitter / receiver 9110 that transmits and receives signals via an antenna 9111. The communication module (transmitter / receiver) 9110 is coupled to the central processing unit 9100 to provide input signals and receive output signals, which can be the same as in the case of a conventional mobile communication terminal.

[0223] Based on different communication technologies, a plurality of communication modules 9110 such as a cellular network module, a Bluetooth module, and / or a wireless local area network module, and the like can be provided in the same electronic device. The communication module (transmitter / receiver) 9110 is also coupled to a speaker 9131 and a microphone 9132 via an audio processor 9130 to provide audio output via the speaker 9131 and receive audio input from the microphone 9132, thereby implementing a conventional telecommunication function. The audio processor 9130 can include any suitable buffer, decoder, amplifier, and the like. In addition, the audio processor 9130 is also coupled to the central processing unit 9100, thereby enabling recording on the local device through the microphone 9132 and enabling playing of a sound stored on the local device through the speaker 9131.

[0224] The embodiment of the present application further provides a computer readable storage medium capable of realizing all steps of the performance analysis method of the SQL statement of the execution subject in the above embodiment, wherein the computer readable storage medium stores a computer program, and the computer program realizes all steps of the performance analysis method of the SQL statement of the execution subject in the above embodiment when executed by a processor, for example, the processor realizes the following steps when executing the computer program:

[0225] S101: parsing the source code to be analyzed according to characteristic attributes of the source code to be analyzed, to obtain corresponding SQL statements to be analyzed; the characteristic attributes at least include table data volume, statement quantity and index parameters;

[0226] S102: determining performance analysis parameters of the SQL statements to be analyzed according to the characteristic attributes; the performance analysis parameters include static analysis parameters and dynamic analysis parameters;

[0227] S103: inputting the static analysis parameters and the dynamic analysis parameters into a pre-constructed SQL statement performance analysis model, to obtain corresponding performance analysis results.

[0228] From the above description, it can be known that the performance analysis method and device of the SQL statement provided by the present application can perform performance analysis on the SQL statement in the source code to be analyzed by combining static analysis and dynamic analysis, effectively improve the writing and optimization efficiency of the SQL statement in the rapid iteration process of software development, and improve the intelligent analysis capability of the performance of the SQL statement in the software product development process.

[0229] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, device or computer program product. Therefore, the present application can adopt a completely hardware embodiment, a completely software embodiment or an embodiment combining software and hardware aspects. Moreover, the present application can adopt a computer program product implemented on one or more computer usable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) containing computer usable program codes.

[0230] The present application is described with reference to flowcharts and / or block diagrams of the method, device (apparatus) and computer program product according to the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of the flows and / or blocks in the flowcharts and / or block diagrams can be realized by computer program instructions. These computer program instructions can be provided to a general purpose computer, a special purpose computer, an embedded processor or other programmable data processing devices to produce a machine, so that the instructions executed by the computer or other programmable data processing devices produce a device for realizing the functions specified in the flowcharts and / or block diagrams. Figure 1apparatuses that implement the functions specified in the flowchart or flowcharts and / or blocks. Figure 1

[0231] These computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture including instructions which implement the flowchart or flowcharts and / or blocks. Figure 1 Figure 1

[0232] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the flowchart or flowcharts and / or blocks. Figure 1 Figure 1

[0233] The principles and implementations of the present application are described in the specific embodiments, the above description of the embodiments is only used to help understand the method of the present application and its core idea; at the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation and application range, and the above description should not be understood as a limitation of the present application.​​​​​

Claims

1. A method of performance analysis of an SQL statement, characterized by, The method comprises the following steps: According to the characteristic attribute of the source code to be analyzed, the source code to be analyzed is parsed to obtain the corresponding SQL statement to be analyzed; According to the characteristic attribute, the performance analysis parameters of the SQL statement to be analyzed are determined; the performance analysis parameters include static analysis parameters and dynamic analysis parameters; wherein the static analysis parameters include table data volume average, table performance attention degree, SQL statement complexity and SQL statement index matching degree; the dynamic analysis parameters include effective execution time and historical execution detail ratio; The static analysis parameters and dynamic analysis parameters are input into the pre-constructed SQL statement performance analysis model to obtain the corresponding performance analysis result; wherein the SQL statement performance analysis model is obtained by inputting historical static analysis parameters and historical dynamic analysis parameters into a neural network regression model for training; Wherein, according to the characteristic attribute, the performance analysis parameters of the SQL statement to be analyzed are determined, including: From the historical database information statistics, the table data volume involved in the SQL statement to be analyzed is obtained, and the table data volume average is calculated according to the table data volume; from the historical database statistical information, the transaction call volume of the table involved in the SQL statement to be analyzed is obtained, and the table performance attention degree is calculated according to the transaction call volume; the SQL statement complexity is obtained by analyzing the number of syntax keywords of the SQL statement to be analyzed; the constraints and indexes of the table involved in the SQL statement to be analyzed are obtained from the historical database statistical information, the data volume of the historical table index column is obtained, and the SQL statement index matching degree is obtained by combining the analysis of the query condition column of the SQL statement to be analyzed and the index configuration relationship; According to the characteristic attribute, the performance analysis parameters of the SQL statement to be analyzed are determined, further comprising: The dynamic execution information of the SQL statement to be analyzed is obtained from the historical database; the dynamic execution information at least includes total execution time, calculation processing time, input / output time and lock waiting time; the effective execution time and historical execution detail ratio are obtained by performing full table scan, full partition scan, index fast full scan and index jump scan on the SQL statement to be analyzed.

2. The method of claim 1, wherein, According to the characteristic attribute of the source code to be analyzed, the source code to be analyzed is parsed to obtain the corresponding SQL statement to be analyzed, comprising: According to the characteristic attribute of the source code to be analyzed, the corresponding syntax tree is generated; According to the keywords in the syntax tree, the SQL statement to be analyzed is determined.

3. The method of claim 1, wherein the SQL statement is a SELECT statement. The static analysis parameters and dynamic analysis parameters are input into the pre-constructed SQL statement performance analysis model to obtain the corresponding performance analysis result, comprising: According to the static analysis parameters and corresponding static analysis weights, the static feature parameters are calculated; According to the dynamic analysis parameters and corresponding dynamic analysis weights, the dynamic feature parameters are calculated; The static feature parameters and the dynamic feature parameters are input into the SQL statement performance analysis model respectively to obtain the corresponding performance analysis result.

4. The method of claim 1, wherein the SQL statement is a SELECT statement. The performance analysis result includes static analysis result and dynamic analysis result; after the static analysis parameters and dynamic analysis parameters are input into the pre-constructed SQL statement performance analysis model to obtain the corresponding performance analysis result, further comprising: comparing the preset static performance analysis threshold with the static analysis result to obtain a first comparison result; comparing the preset dynamic performance analysis threshold with the dynamic analysis result to obtain a second comparison result; when the first comparison result and the second comparison result are both passed, determining that the performance of the SQL statement to be analyzed is up to standard.

5. An apparatus for performance analysis of an SQL statement, characterized by comprising: comprising: a SQL statement extraction unit configured to parse the source code to be analyzed according to a characteristic attribute of the source code to be analyzed to obtain a corresponding SQL statement to be analyzed; the characteristic attribute at least includes table data volume, statement quantity, and index parameter; an analysis parameter determination unit configured to determine performance analysis parameters of the SQL statement to be analyzed according to the characteristic attribute; the performance analysis parameters include static analysis parameters and dynamic analysis parameters; the static analysis parameters include table data volume average, table performance attention degree, SQL statement complexity, and SQL statement index matching degree; the dynamic analysis parameters include effective execution time and historical execution detail ratio; a performance analysis unit configured to input the static analysis parameters and the dynamic analysis parameters into a pre-constructed SQL statement performance analysis model to obtain a corresponding performance analysis result; the SQL statement performance analysis model is obtained by inputting historical static analysis parameters and historical dynamic analysis parameters into a neural network regression model for training; wherein the static analysis parameters are obtained by: obtaining table data volume involved in the SQL statement to be analyzed from historical database information statistics, and calculating the table data volume average according to the table data volume; obtaining transaction call volume of a table involved in the SQL statement to be analyzed from historical database statistics, and calculating the table performance attention degree according to the transaction call volume; analyzing the SQL statement complexity by analyzing the number of syntax keywords of the SQL statement to be analyzed; obtaining constraints and indexes of a table involved in the SQL statement to be analyzed from historical database statistics, obtaining data volume of a historical table index column, and obtaining the SQL statement index matching degree by combining analysis of a query condition column of the SQL statement to be analyzed and index configuration relationship; the dynamic analysis parameters are obtained by: obtaining dynamic execution information of the SQL statement to be analyzed from a historical database; the dynamic execution information at least includes total execution time, calculation processing time, input / output time, and lock waiting time; performing full table scanning, full partition scanning, index fast full scanning, and index jump scanning on the SQL statement to be analyzed to obtain the effective execution time and the historical execution detail ratio.

6. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the program to realize the steps of the SQL statement performance analysis method of any one of claims 1 to 4.

7. A computer-readable storage medium having stored thereon a computer program, characterized in that The computer program is executed by the processor to realize the steps of the SQL statement performance analysis method of any one of claims 1 to 4.

8. A computer program product comprising computer programs / instructions, characterized in that, The computer program / instruction is executed by the processor to realize the steps of the SQL statement performance analysis method of any one of claims 1 to 4.

Citation Information

Patent Citations

  • Method for discovering binary code vulnerability based on function model

    CN101814053A

  • Low-efficiency SQL statement analysis method and system based on distributed database cluster

    CN111046059A