SQL statement processing method, device, electronic device and storage medium

By building a target execution time-consuming prediction function, predicting and processing SQL statements that may be slow in advance, the problem of extended processing time and reduced efficiency of slow SQL statements in the prior art is solved, and more efficient SQL statement processing is achieved.

CN113297247BActive Publication Date: 2025-02-25ALIBABA GROUP HOLDING LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010722186.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-07-24
Publication Date
2025-02-25
Estimated Expiration
2040-07-24

AI Technical Summary

Technical Problem

In the prior art, when processing slow SQL statements, it is usually necessary to passively wait for slow SQL statements to appear before processing, resulting in extended processing time and reduced efficiency.

Method used

By obtaining the historical capacity data and historical execution time-consuming data of the historical database table associated with the target SQL statement, building a target execution time-consuming prediction function, predicting the execution time-consuming of SQL statements under different capacity data, and processing SQL that may be slow in advance is possible in advance Statement.

Benefits of technology

It reduces the processing time of slow SQL statements, improves the processing efficiency of slow SQL statements, and avoids delays caused by waiting processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113297247B_ABST
    Figure CN113297247B_ABST
Patent Text Reader

Abstract

The present application provides a method for obtaining historical capacity data of a historical database table associated with a target SQL statement; obtaining historical execution time data of the target SQL statement when the historical database table corresponds to the historical capacity data; obtaining a target execution time prediction function corresponding to the target SQL statement based on the historical execution time data and the historical capacity data; inputting the target capacity data of the target associated database table into the target execution time prediction function to obtain the target execution time data of the target SQL statement. The SQL statement processing method provided by the present application enables relevant personnel to predict in advance whether the target SQL statement will become a slow SQL statement based on the target execution time data, and then process the target SQL statement before the target SQL statement becomes a slow SQL statement, thereby reducing the processing time of the slow SQL statement and improving the processing efficiency of the slow SQL statement.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and more particularly to a method for processing SQL statements. The present invention also relates to a device for processing SQL statements, an electronic device, and a storage medium. Background Art

[0002] With the advent of the Internet+ and big data era, the data types and data scales in database systems are increasing rapidly, so how to manage database systems has become a new challenge. Among them, SQL (Structured Query Language) as a database language with multiple functions such as data manipulation and data definition provides great convenience for relevant data managers to manage database systems. SQL can be divided into three parts from the functional point of view: data definition, data manipulation and data control. Specifically, data management operations such as data access, query, insert, update and delete are performed through SQL statements. In a database system, data is often stored in the form of database tables. Database tables are a grid virtual table used in databases to store data. A database system usually contains multiple database tables, and an SQL statement may be associated with only one database table or multiple database tables.

[0003] Generally, as the data capacity of the database table associated with an SQL statement increases, the execution time of the SQL statement will also increase, and eventually it will become a slow SQL statement whose execution time exceeds the preset execution time. In addition, in other cases, the execution time of SQL statements will also increase, and then it will become a slow SQL statement whose execution time exceeds the preset execution time. Slow SQL statements will reduce the management efficiency of the database system.

[0004] In order to ensure the management efficiency of the database system, it is often necessary to process slow SQL statements to slow down or prevent them from becoming slow SQL statements. In the existing slow SQL statement processing method, it is generally necessary to passively wait for the slow SQL statement to appear, and then process the slow SQL statement after the slow SQL statement appears, that is, one case is found and processed. In this way, the processing of slow SQL statements often occurs after the slow SQL statement appears, thereby extending the processing time of slow SQL statements and reducing the processing efficiency of slow SQL statements. Summary of the invention

[0005] The present application provides a SQL statement processing method, device, electronic device and storage medium to reduce the processing time of slow SQL statements and improve the processing efficiency of slow SQL statements.

[0006] The present application provides a SQL statement processing method, including:

[0007] Obtain historical capacity data of the historical database table associated with the target SQL statement;

[0008] Obtaining historical execution time consumption data of the target SQL statement when the historical database table corresponds to the historical capacity data;

[0009] Obtaining a target execution time prediction function corresponding to the target SQL statement according to the historical execution time data and the historical capacity data;

[0010] The target capacity data of the target associated database table is input into the target execution time consumption prediction function to obtain the target execution time consumption data of the target SQL statement.

[0011] Optionally, the target execution time consumption prediction function is used to predict the execution time consumption data of the target SQL statement when the associated database table corresponds to the specified capacity data;

[0012] The step of inputting the target capacity data of the target associated database table into the target execution time prediction function to obtain the target execution time data of the target SQL statement includes: inputting the target capacity data into the target execution time prediction function, and obtaining the target execution time data when the target associated database table corresponds to the target capacity data, wherein the target associated database table is a target database table associated with the target SQL statement.

[0013] 3. The SQL statement processing method according to claim 2, characterized in that the target execution time prediction function is used to predict the capacity data of the database table associated with the target SQL statement when the database table associated with the target SQL statement corresponds to the specified execution time data;

[0014] The SQL statement processing method further includes: inputting the preset execution time consumption data of the target associated database table into the target execution time consumption prediction function, and obtaining the predicted capacity data of the target associated database table when the target associated database table corresponds to the preset execution time consumption data.

[0015] Optionally, it also includes: obtaining the time point when the target execution time data reaches the execution time threshold.

[0016] Optionally, it also includes: displaying at least one of the target execution time-consuming data and the time point.

[0017] Optionally, also include:

[0018] Obtaining an execution time-consuming query request message sent by a user terminal for the target SQL statement;

[0019] In response to the execution time query request message, at least one of the target execution time data and the time point is provided to the user terminal.

[0020] Optionally, obtaining a target execution time prediction function corresponding to the target SQL statement according to the historical execution time data and the historical capacity data includes:

[0021] Constructing a cost function for obtaining the target execution time prediction function according to the historical execution time data and the historical capacity data;

[0022] When the value of the cost function is less than the target value, the target execution time prediction function is obtained.

[0023] Optionally, constructing a cost function for obtaining the target execution time prediction function according to the historical execution time data and the historical capacity data includes:

[0024] Determine, according to the historical database table, a candidate execution time-consuming prediction function corresponding to the target SQL statement;

[0025] Determine a mapping relationship between the historical execution time consumption data and the historical capacity data according to the historical execution time consumption data and the historical capacity data;

[0026] The cost function is constructed according to the candidate execution time-consuming prediction function and the mapping relationship.

[0027] Optionally, when the value of the cost function is less than the target value, the target execution time prediction function is obtained, including: iterating the cost function according to the historical execution time data and the historical capacity data, and obtaining the candidate execution time prediction function when the value of the cost function is less than the target value as the target execution time prediction function.

[0028] Optionally, determining, according to the historical database table, a candidate execution time-consuming prediction function corresponding to the target SQL statement includes:

[0029] According to the historical database table, obtaining the to-be-determined parameters of the candidate execution time-consuming prediction function;

[0030] Determine the candidate execution time-consuming prediction function according to the parameters to be determined;

[0031] The constructing the cost function according to the candidate execution time-consuming prediction function and the mapping relationship includes:

[0032] Determine a Euclidean distance error function between the candidate execution time prediction function and the mapping relationship according to the candidate execution time prediction function and the mapping relationship;

[0033] The Euclidean distance error function is used as the cost function.

[0034] Optionally, iterating the cost function according to the historical execution time consumption data and the historical capacity data to obtain the candidate execution time consumption prediction function when the value of the cost function is less than the target value as the target execution time consumption prediction function includes:

[0035] The Euclidean distance error function is iterated for the parameter to be determined, and the candidate execution time prediction function is obtained when the value of the Euclidean distance error function is less than the target value, and is used as the target execution time prediction function.

[0036] Optionally, obtaining the historical capacity data of the historical database table associated with the target SQL statement includes: obtaining the historical capacity data of the historical database table in different time intervals.

[0037] Optionally, obtaining the historical execution time data of the target SQL statement when the historical database table corresponds to the historical capacity data includes: obtaining the historical execution time data of the target SQL statement in different time intervals in the historical database table.

[0038] Optionally, obtaining the historical execution time-consuming data of the target SQL statement in different time intervals in the historical database table includes:

[0039] Obtain multiple historical execution time-consuming data of the target SQL statement in different time intervals in the historical database table;

[0040] The average of multiple historical execution time-consuming data of the target SQL statement in the different time intervals in the historical database table is used as the historical execution time-consuming data of the target SQL statement in the different time intervals in the historical database table.

[0041] In another aspect, the present application further provides a SQL statement processing device, comprising:

[0042] A historical capacity data acquisition unit, used to acquire historical capacity data of a historical database table associated with a target SQL statement;

[0043] A historical execution time consumption data obtaining unit, used for obtaining the historical execution time consumption data of the target SQL statement when the historical database table corresponds to the historical capacity data;

[0044] A target execution time consumption prediction function obtaining unit, used for obtaining a target execution time consumption prediction function corresponding to the target SQL statement according to the historical execution time consumption data and the historical capacity data;

[0045] The target execution time consumption data obtaining unit is used to input the target capacity data of the target associated database table into the target execution time consumption prediction function to obtain the target execution time consumption data of the target SQL statement.

[0046] In another aspect, the present application further provides an electronic device, comprising:

[0047] Processor; and

[0048] The memory is used to store the program for the SQL statement processing method. After the device is powered on and the program for the SQL statement processing method is run by the processor, the following steps are performed:

[0049] Obtain historical capacity data of the historical database table associated with the target SQL statement;

[0050] Obtaining historical execution time consumption data of the target SQL statement when the historical database table corresponds to the historical capacity data;

[0051] Obtaining a target execution time prediction function corresponding to the target SQL statement according to the historical execution time data and the historical capacity data;

[0052] The target capacity data of the target associated database table is input into the target execution time consumption prediction function to obtain the target execution time consumption data of the target SQL statement.

[0053] On the other hand, the present application further provides a storage device storing a program for the SQL statement processing method, wherein the program is executed by a processor to perform the following steps:

[0054] Obtain historical capacity data of the historical database table associated with the target SQL statement;

[0055] Obtaining historical execution time consumption data of the target SQL statement when the historical database table corresponds to the historical capacity data;

[0056] Obtaining a target execution time prediction function corresponding to the target SQL statement according to the historical execution time data and the historical capacity data;

[0057] The target capacity data of the target associated database table is input into the target execution time consumption prediction function to obtain the target execution time consumption data of the target SQL statement.

[0058] On the other hand, the present application also provides a SQL statement processing method, including:

[0059] Obtaining a query request message sent by a user terminal for a target SQL statement;

[0060] In response to the query request message, obtaining historical capacity data of the historical database table associated with the target SQL statement;

[0061] Obtaining historical execution time consumption data of the target SQL statement when the historical database table corresponds to the historical capacity data;

[0062] Obtaining a target execution time prediction function corresponding to the target SQL statement according to the historical execution time data and the historical capacity data;

[0063] Inputting the target capacity data of the target associated database table into the target execution time prediction function to obtain the target execution time data of the target SQL statement;

[0064] The target execution time consumption data is provided to the user terminal.

[0065] On the other hand, the present application also provides a SQL statement processing method, including:

[0066] Obtaining a processing request message sent by a user terminal for a target SQL statement;

[0067] In response to the query request message, obtaining historical capacity data of the historical database table associated with the target SQL statement;

[0068] Obtaining historical execution time consumption data of the target SQL statement when the historical database table corresponds to the historical capacity data;

[0069] Obtaining a target execution time prediction function corresponding to the target SQL statement according to the historical execution time data and the historical capacity data;

[0070] Input the target capacity data of the target associated database table into the target execution time prediction function to obtain the target execution time data of the target SQL statement:

[0071] A time point when the target execution time consumption data reaches an execution time consumption threshold is obtained, and before the time point, duplicate data in the target associated database table is deleted.

[0072] Compared with the prior art, this application has the following advantages:

[0073] The present application provides a method for processing SQL statements. After obtaining the historical capacity data of the historical database table associated with the target SQL statement, the historical execution time data of the target SQL statement when the historical database table corresponds to the historical capacity data is further obtained; then, based on the historical execution time data and the historical capacity data, a target execution time prediction function corresponding to the target SQL statement is obtained; and then the target capacity data of the target associated database table is input into the target execution time prediction function to obtain the target execution time data of the target SQL statement. The SQL statement processing method provided by the present application can input the target capacity data of the target associated database table into the target execution time prediction function to obtain the target execution time data of the target SQL statement, so that relevant personnel can predict in advance whether the target SQL statement will become a slow SQL statement based on the target execution time data, and then can process the target SQL statement before the target SQL statement becomes a slow SQL statement, thereby reducing the processing time of the slow SQL statement and improving the processing efficiency of the slow SQL statement. BRIEF DESCRIPTION OF THE DRAWINGS

[0074] Figure 1 This is a flowchart of the SQL statement processing method provided in the first embodiment of the present application.

[0075] Figure 1A This is a schematic diagram of the SQL statement processing module provided in the first embodiment of the present application.

[0076] Figure 2 This is a schematic diagram of the SQL statement processing device provided in the second embodiment of the present application.

[0077] Figure 3 This is a schematic diagram of an electronic device provided in the first embodiment of the present application.

[0078] Figure 4 This is a flowchart of the SQL statement processing method provided in the fifth embodiment of the present application.

[0079] Figure 5 This is a flowchart of the SQL statement processing method provided in the sixth embodiment of the present application. DETAILED DESCRIPTION

[0080] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.

[0081] First embodiment

[0082] In order to more clearly demonstrate the target SQL statement processing method provided by the present application, the application scenario of the SQL statement processing method provided by the present application is first introduced. In actual applications, the SQL statement processing method provided by the first embodiment of the present application is generally used in the scenario of processing slow SQL statements in the process of database system management. The so-called database system DBS (Data Base System, referred to as DBS) is usually composed of software, database and data administrator. The so-called software mainly includes operating system, various host languages, utility programs and database management system. The so-called data administrator is responsible for creating, monitoring and maintaining the entire database so that the data can be effectively used by anyone who has the right to use it. The so-called database is a data set that organizes, stores and manages data according to the data structure. The so-called data includes company operating data, application running programs, web browsing data, personal consumption data, etc. The so-called data in the first embodiment of the present application can be continuous values, such as sound, image, etc., or discrete values, such as symbols and text. The so-called database table is a file in the database that stores and manages data in a tabular form. The so-called database is uniformly managed by the database management system, and the insertion, modification and retrieval of data must be carried out through the database management system. Specifically, when a database management system manages data in a database table, it uses SQL statements to perform data management operations such as access, query, insert, update, and delete data.

[0083] The execution subject of the SQL statement processing method provided in the first embodiment of the present application is a computing device installed with an application or software for executing the SQL statement processing method provided in the first embodiment of the present application. In terms of specific implementation, it is generally a user terminal for executing the application or software of the SQL statement processing method provided in the first embodiment of the present application, such as: a smart phone, a tablet computer installed with an application for executing the SQL statement processing method provided in the first embodiment of the present application, and a computer for executing the software of the SQL statement processing method provided in the first embodiment of the present application. In addition, the execution subject of the SQL statement processing method provided in the first embodiment of the present application can also be an application or software installed on a computing device for executing the SQL statement processing method provided in the first embodiment of the present application, a server or a server cluster that provides services such as data processing. In the first embodiment of the present application, the SQL statement processing method provided in the first embodiment of the present application is described in detail by taking the execution subject as a server as an example. For details, please refer to Figure 1 :

[0084] When the data administrator processes the target SQL statement, he will first send a processing request message to the server for the target SQL statement through the user terminal. After receiving the request message sent by the user terminal, the server 102 will obtain the historical capacity data of the historical database table associated with the target SQL statement in response to the processing request message (i.e., step S101). The so-called historical database table is the database table associated with the target SQL statement in a specified historical time interval, and the so-called historical capacity data of the historical database table associated with the target SQL statement is the amount of data stored in the historical database table in the specified historical time interval. Since the data stored in the database table associated with the target SQL statement will be different in different periods, in the first embodiment of the present application, the database tables before the current time point are collectively referred to as historical database tables according to the period in which the database table associated with the target SQL statement is located.

[0085] In the first embodiment of the present application, when the server 102 processes the target SQL statement, it is generally implemented through a SQL statement processing system, such as Figure 1A As shown, the SQL statement processing system includes: a data acquisition module 101, a data integration module 102 and an iterative calculation module 103. The step of obtaining the historical capacity data of the historical database table associated with the target SQL statement in the first embodiment of the present application can be implemented by the data acquisition module 101. Since the data stored in the database table will change with time, the data capacity of the historical database table in the first embodiment of the present application may also change in different time intervals. Therefore, in the first embodiment of the present application, the specific implementation method of the data acquisition module 101 obtaining the historical capacity data is: obtaining the historical capacity data of the historical database table in different time intervals through the capacity data acquisition module 101-1.

[0086] Please refer to Figure 1 After obtaining the historical capacity data, in the first embodiment of the present application, it is necessary to further obtain the historical execution time data of the target SQL statement when the historical database table corresponds to the historical capacity data (i.e., step S102). The so-called historical execution time data refers to the time data when the target SQL statement performs operations such as access, query, insert, update, and delete on the data in the historical database table.

[0087] like Figure 1AAs shown, the step of obtaining the historical execution time data in the first embodiment of the present application can be implemented by the data acquisition module 101. Since the data stored in the database table will change with time, when the historical database table changes, the execution time data of the target SQL will also change. Therefore, the specific implementation method of the data acquisition module 101 to obtain the historical execution time data is: obtain multiple historical execution time data of the target SQL statement in different time intervals of the historical database table through the execution time data acquisition module 101-2. The average of the multiple historical execution time data of the target SQL statement in different time intervals of the historical database table is used as the historical execution time data of the target SQL statement in different time intervals of the historical database table.

[0088] It should be noted that the database table associated with the target SQL statement may not only be a separate table, but may also be a database table composed of a main table and multiple related tables. The so-called main table is not a table used to store preset main information, such as: a table used to record personal consumption time, location, amount and other data in a database table for storing personal consumption; the so-called related table is a table that depends on the main table and is used to store related information of the main information, such as: a table used to store amount data details in a database table for storing personal consumption. Therefore, in the first embodiment of the present application, when obtaining the historical capacity data of the historical database table, it is necessary to obtain the main table, the related table of the historical database table, and the historical data capacity of the main table and the related table of each table.

[0089] Please refer to Figure 1 After obtaining the historical execution time data and the historical capacity data, the first embodiment of the present application needs to further obtain the target execution time prediction function for the target execution time prediction function, and obtain the time point when the target execution time data reaches the execution time threshold. Figure 1 As shown, at this time, in the first embodiment of the present application, step S103 needs to be further executed: according to the historical execution time consumption data and the historical capacity data, a target execution time consumption prediction function corresponding to the target SQL statement is obtained.

[0090] The so-called target execution time prediction function is a prediction function used to predict the execution time data of the target SQL statement when the associated database table corresponds to the specified capacity data. In the first embodiment of the present application, the scheme for obtaining the target execution time prediction function is: first, based on the historical execution time data and the historical capacity data, fit the curve relationship between the historical capacity data and the historical execution time data. Then, through the cost function, fit the function that is closest to the curve relationship between the historical capacity data and the historical execution time data as the target execution time prediction function. That is, after determining the cost function, iterate the cost function according to the historical execution time data and the historical capacity data to obtain a candidate execution time prediction function when the value of the cost function is less than the target value, as the target execution time prediction function.

[0091] In the first embodiment of the present application, the implementation process of the solution for obtaining the target execution time prediction function is as follows: first, a cost function for obtaining the target execution time prediction function is constructed based on historical execution time data and historical capacity data. Then, when the value of the cost function is less than the target value, the target execution time prediction function is obtained.

[0092] The specific implementation method of constructing a cost function for obtaining a target execution time prediction function based on historical execution time data and historical capacity data is as follows: first, determine the candidate execution time prediction function corresponding to the target SQL statement based on the historical database table. Then, determine the mapping relationship between the historical execution time data and the historical capacity data based on the historical execution time data and the historical capacity data. Finally, construct a cost function based on the candidate execution time prediction function and the mapping relationship.

[0093] In the first embodiment of the present application, the specific implementation method of determining the candidate execution time prediction function corresponding to the target SQL statement according to the historical database table is: obtaining the to-be-determined parameters of the candidate execution time prediction function according to the historical database table; determining the candidate execution time prediction function according to the to-be-determined parameters. In the embodiment of the present application, the so-called to-be-determined parameters are the parameters of the candidate execution time prediction function or the target execution time prediction function used to determine the execution time data according to the capacity data.

[0094] In the embodiment of the present application, when obtaining the parameters to be determined of the candidate execution time prediction function, it is necessary to consider the composition of the historical database table associated with the target SQL statement and whether the table constituting the historical database table has an index. If there is only one table constituting the historical database table and it has an index, then the parameter of the candidate execution time prediction function is only p1. At this time, the formula corresponding to the candidate execution time prediction function is: h p (x (i))=pO(logN)......(1). If the table constituting the historical database table is only one table and has no index, then the parameter to be determined of the candidate execution time prediction function is only p1. At this time, the formula corresponding to the candidate execution time prediction function is: p (x (i) )=pO(N)......(2) N is the historical data capacity of the historical database.

[0095] Since the situation when a database table has more than one table accounts for the majority of the situations of the database table, and when a database table has more than one table, it is generally that the database table has one main table and two associated tables, therefore, in the first embodiment of the present application, the process of determining the candidate execution time prediction function in the first embodiment of the present application is specifically described by taking the historical database table including one main table and two associated tables as an example. If the historical database table includes one main table and two associated tables, the parameters of the candidate execution time prediction function are p1-p 10 At this time, the formula corresponding to the candidate execution time prediction function is: p (x (i) )=p1O(N1)+p2O(N2)+p3O(N3)+p1O(logN1)+p2O(logN2)+p3O(logN3)+p4O(N1)O(N2)O(N3)+p5(logN1)(logN2)(logN3)++p5O(N1 )O(logN2)O(N3)+p6O(N1)O(N2)O(logN3)+p7O(logN1)O(logN2)O(N3)+p8O(N1)O(logN2)O(logN3)+p9O(N1)O(logN2)O(logN3)+p 10 O(logN1)O(logN2)O(logN3)......(3)

[0096] In addition, in the first embodiment of the present application, when the historical database table includes a main table and two associated tables, the target SQL statement can be specifically a statement in the following form: "SELECT*FROM detail AS origin1 LEFT JOIN(SELECT*FROM flag_sum)AS origin2 ON origin1.work_no=origin2.work_no LEFTJOIN(SELECT*FROM worklist)AS origin3 ON origin1.super_work_no=origin3.work_no". That is, "query the data in the details table whose number is the same as the work number in the indication total table as data source 1 and data source 2, and return the row numbers of data source 1 and data source 2 in their respective tables, query the data in the work list whose work number is the same as source 1 as data source 3, and return the row number of data source 3 in its table". Among them, the target SQL statement involves three associated tables: the first is the details table (i.e., FROMdetail), the second is the indication total table (i.e., FROM flag_sum), and the third is the details table (i.e., FROM worklist).

[0097] After determining the formula corresponding to the candidate execution time prediction function, a cost function can be further constructed based on the formula corresponding to the candidate execution time prediction function and the mapping relationship. In the first embodiment of the present application, the specific implementation method of the constructed cost function is: the Euclidean distance error function of the formula corresponding to the candidate execution time prediction function and the mapping relationship, that is, the function of solving the mean value of the Euclidean distance error of the formula corresponding to the candidate execution time prediction function and the mapping relationship. If the so-called mapping relationship is recorded as: y (i) , then the constructed cost function is: Where m is the number of different time intervals.

[0098] Since the cost function constructed in the first embodiment of the present application is a Euclidean distance error function, the cost function is iterated to obtain a candidate execution time prediction function when the cost function value is less than the target value, and the specific implementation method as the target execution time prediction function is: for the parameters to be determined, the Euclidean distance error function is iterated to obtain a candidate execution time prediction function when the Euclidean distance error function value is less than the target value, and the target execution time prediction function is used. The specific implementation process is as follows:

[0099] In the first embodiment of the present application, the specific strategy for iterating the constructed cost function as the Euclidean distance error function is the gradient descent method, and the specific implementation method is: first, according to the cost function, obtain the parameters p1-p for the candidate execution time prediction function10 The partial derivative of Where j is p1-p 10 Then change p j Adjust in the direction of the maximum partial derivative until the value of the Euclidean distance error function is less than the target value.

[0100] The so-called parameter p1-p of the candidate execution time prediction function is obtained 10 The partial derivative of is: according to the candidate execution time prediction function, find the partial derivative of the parameters of the candidate execution time prediction function. j Adjust in the direction of the maximum partial derivative: According to the formula The p j Adjust in the direction of the maximum partial derivative. j′ is the adjusted p1-p 10 , α is the learning rate, which is any value between 0 and 1.

[0101] In the first embodiment of the present application, the learning rate determination process is as follows: an empirical value is obtained as the initial learning rate, such as 0.1, and the number of iterations of the sample Euclidean distance error function used for learning rate training is set to 500. After iterating the sample Euclidean distance error function 500 times, the initial value of the sample Euclidean distance error function is obtained, the initial learning rate is increased by 10% to 0.11, and the sample Euclidean distance error function is iterated 500 times to obtain the secondary iteration value of the sample Euclidean distance error function to see whether the secondary iteration value becomes smaller. If the secondary iteration value becomes smaller, then after each iteration of the sample Euclidean distance error function 500 times, the learning rate is increased by 10% until the secondary iteration value no longer becomes smaller, and the learning rate at this time is determined to be the target learning rate.

[0102] The process until the value of the Euclidean distance error function is less than the target value is as follows: randomly generate a set of p1-p 10 As the first parameter of the candidate execution time prediction function, the first parameter, historical execution time data and historical capacity data are substituted into formula (3) to obtain the first calculated value of the Euclidean distance error function. Compare whether the first calculated value is less than the target value. If so, the candidate execution time prediction function is used as the target execution time prediction function. At this time, the first parameter is the parameter of the target execution time prediction function.

[0103] If not, substitute the first parameter into formula (4) to obtain the second parameter of the candidate execution time prediction function. Substitute the second parameter, historical execution time data and historical capacity data into formula (3) to obtain the second calculated value of the Euclidean distance error function. Compare whether the second calculated value is less than the target value. If so, use the candidate execution time prediction function as the target execution time prediction function. At this time, the second parameter is the parameter of the target execution time prediction function. If the second calculated value is not less than the target value, perform the above steps in sequence until the value of the Euclidean distance error function is less than the target value, and obtain the target execution time prediction function.

[0104] Please refer to Figure 1A , since in the first embodiment of the present application, it is also necessary to determine the main table and multiple associated tables constituting the historical database table, the main table and multiple associated tables in the historical database table can be determined specifically by the database table determination module 101-3. In addition, after obtaining the main table and multiple associated tables of the historical database table, the historical execution time consumption data and the historical capacity data, the data integration module 102 will integrate the main table and multiple associated tables of the historical database table, the historical execution time consumption data and the historical capacity data, and use the integrated main table and multiple associated tables of the historical database table, the historical execution time consumption data and the historical capacity data as the historical data for fitting the cost function.

[0105] In addition, in the first embodiment of the present application, the iterative calculation module 103 is used to fit the cost function to obtain the target execution time prediction function, and obtain the target execution time data according to the target execution time prediction function. Specifically, the iterative calculation module 103 includes: a learning rate acquisition module 103-1, which is used to determine the learning rate; a cost function value determination module 103-2, which is used to determine the value of the cost function; and a target value determination module 103-3, which is used to compare whether the value of the cost function is less than the target value.

[0106] Please refer to Figure 1 In the first embodiment of the present application, since the target execution time prediction function is used to predict the execution time data of the target SQL statement when the associated database table corresponds to the specified capacity data. Therefore, after obtaining the target execution time prediction function, step S104 can be further executed: input the target capacity data of the target associated database table into the target execution time prediction function to obtain the target execution time data of the target SQL statement. That is, input the target capacity data into the target execution time prediction function, and when the target associated database table corresponds to the target capacity data, the target execution time data is obtained, and the target associated database table is the target database table associated with the target SQL statement. Since the target execution time data corresponds to formula (3), after determining the target capacity data, the target execution time data can be obtained based on the target capacity data and formula (3).

[0107] In addition, in the first embodiment of the present application, after obtaining the target execution time data, the time point when the target execution time data reaches the execution time threshold can be further obtained (i.e., step S104-1). The so-called pre-set execution time threshold is the threshold of the slow SQL statement. When the target execution time data reaches the execution time threshold, the target SQL statement is a slow SQL statement. After obtaining the above-mentioned time point, the server can also generate a SQL statement processing scheme for processing the target SQL statement for processing the request message, and display it or provide it to the user terminal. At this time, the data management personnel can use the server to process the data in the target associated database table or optimize the target SQL statement according to the SQL statement processing scheme provided by the server before the time point for processing the request message. (i.e., step S104-2). That is, the so-called SQL statement processing scheme at least includes one of data processing of the data in the target associated database table and data processing of the data in the target associated database table. The so-called specific implementation method of data processing on the data in the target associated database table, such as: deleting duplicate data in the target associated database table, adding indexes to the tables in the target associated database table, etc., so as to extend the time of the target SQL statement, i.e., the slow SQL statement; another example: obtaining the main table and associated table in the target associated database table that do not have indexes, and establishing indexes for the target SQL statement for the main table and associated table that do not have indexes. The so-called specific implementation method of optimizing the target SQL statement, such as: if the target SQL statement has a where (data location query) clause for querying the data location, then it is necessary to avoid using parameters in the where clause, because this will cause the target SQL statement to perform a full table scan on the target associated database table, thereby increasing the execution time data. In the first embodiment of the present application, the target execution time prediction function is also used to predict the capacity data of the database table associated with the target SQL statement when the database table associated with the target SQL statement corresponds to the specified execution time data. Since the target execution time data corresponds to formula (3), after determining the preset execution time data, the predicted capacity data can be obtained according to the preset execution time data and formula (3). Therefore, after obtaining the target execution time prediction function, the preset execution time data of the target associated database table can be further input into the target execution time prediction function to obtain the predicted capacity data of the target associated database table when the preset execution time data corresponding to the target associated database table is obtained.

[0108] Please refer to Figure 1A In the first embodiment of the present application, the specific execution module for obtaining the target execution time data according to the target capacity data and formula (3) is the prediction module 103-4 in the iterative calculation module 103.

[0109] Please refer to Figure 1 In the first embodiment of the present application, after obtaining the target execution time data and time point, the server can also display at least one of the following. In addition, if the server obtains an execution time query request message sent by the user terminal for the target SQL statement, the server will provide at least one of the target execution time data and time point to the user terminal for the execution time query request message.

[0110] When the target SQL statement becomes a slow SQL statement, the target SQL statement processing method provided in the first embodiment of the present application can further obtain a SQL statement whose operation type and capacity data are the same or similar to the target SQL statement according to the operation type and target capacity data of the target SQL statement, and use the SQL statement whose operation type and capacity data are the same or similar to the target SQL statement as a SQL statement that may also become a slow SQL statement when the capacity data reaches the preset capacity data. Before the capacity number of the SQL statements whose operation type and capacity data are the same or similar to the target SQL statement reaches the preset capacity data, data processing is performed on the data in the database table associated with the SQL statement, or the SQL statement is optimized.

[0111] It should be noted that the target SQL statement processing method provided in the first embodiment of the present application can not only be used for processing slow SQL statements in the database system management process, but also can be used in other related application scenarios. That is, the application scenario of the target SQL statement processing method is not specifically limited in the first embodiment of the present application.

[0112] The SQL statement processing method provided in the first embodiment of the present application, after obtaining the historical capacity data of the historical database table associated with the target SQL statement, further obtains the historical execution time data of the target SQL statement when the historical database table corresponds to the historical capacity data; then, according to the historical execution time data and the historical capacity data, obtains the target execution time prediction function corresponding to the target SQL statement; and then inputs the target capacity data of the target associated database table into the target execution time prediction function to obtain the target execution time data of the target SQL statement. The SQL statement processing method provided in the first embodiment of the present application can input the target capacity data of the target associated database table into the target execution time prediction function to obtain the target execution time data of the target SQL statement, so that relevant personnel can predict in advance whether the target SQL statement will become a slow SQL statement based on the target execution time data, and then can process the target SQL statement before the target SQL statement becomes a slow SQL statement, thereby reducing the processing time of the slow SQL statement and improving the processing efficiency of the slow SQL statement.

[0113] Second embodiment

[0114] Corresponding to the SQL statement processing method provided in the first embodiment of the present application, the second embodiment of the present application also provides a SQL statement processing device. Since the device embodiment is basically similar to the first embodiment of the present application, the description is relatively simple, and the relevant parts can be referred to the partial description of the first embodiment of the present application. The device embodiment described below is only illustrative.

[0115] Please refer to Figure 2 , which is a schematic diagram of an SQL statement processing device provided in the second embodiment of the present application.

[0116] The SQL statement processing device comprises:

[0117] A historical capacity data obtaining unit 201 is used to obtain historical capacity data of a historical database table associated with a target SQL statement;

[0118] A historical execution time consumption data obtaining unit 202 is used to obtain the historical execution time consumption data of the target SQL statement when the historical database table corresponds to the historical capacity data;

[0119] A target execution time consumption prediction function obtaining unit 203 is used to obtain a target execution time consumption prediction function corresponding to the target SQL statement according to the historical execution time consumption data and the historical capacity data;

[0120] The target execution time consumption data obtaining unit 204 is used to input the target capacity data of the target associated database table into the target execution time consumption prediction function to obtain the target execution time consumption data of the target SQL statement.

[0121] Optionally, the target execution time consumption prediction function is used to predict the execution time consumption data of the target SQL statement when the associated database table corresponds to the specified capacity data;

[0122] The target execution time data acquisition unit 204 is specifically used to input the target capacity data into the target execution time prediction function, and obtain the target execution time data when the target associated database table corresponds to the target capacity data. The target associated database table is the target database table associated with the target SQL statement.

[0123] Optionally, the target execution time prediction function is used to predict the capacity data of the database table associated with the target SQL statement when the database table associated with the target SQL statement corresponds to the specified execution time data;

[0124] The SQL statement processing device provided in the second embodiment of the present application also includes: a predicted capacity data acquisition unit, which is used to input the preset execution time data of the target associated database table into the target execution time prediction function, and obtain the predicted capacity data of the target associated database table when the target associated database table corresponds to the preset execution time data.

[0125] The SQL statement processing device provided in the second embodiment of the present application also includes: a time point obtaining unit, which is used to obtain the time point when the target execution time data reaches the execution time threshold.

[0126] Optionally, the SQL statement processing device provided in the second embodiment of the present application further includes: a data display unit, used to display at least one of the target execution time-consuming data and the time point.

[0127] Optionally, the SQL statement processing device provided in the second embodiment of the present application further includes:

[0128] A query request obtaining unit, used to obtain an execution time-consuming query request message sent by a user terminal for the target SQL statement;

[0129] A data providing unit is used to provide at least one of the target execution time consumption data and the time point to the user terminal in response to the execution time consumption query request message.

[0130] Optionally, the target execution time prediction function obtaining unit 203 is specifically used to construct a cost function for obtaining the target execution time prediction function based on the historical execution time data and the historical capacity data; when the value of the cost function is less than the target value, the target execution time prediction function is obtained.

[0131] Optionally, constructing a cost function for obtaining the target execution time prediction function according to the historical execution time data and the historical capacity data includes:

[0132] Determine, according to the historical database table, a candidate execution time-consuming prediction function corresponding to the target SQL statement;

[0133] Determine a mapping relationship between the historical execution time consumption data and the historical capacity data according to the historical execution time consumption data and the historical capacity data;

[0134] The cost function is constructed according to the candidate execution time-consuming prediction function and the mapping relationship.

[0135] Optionally, when the value of the cost function is less than the target value, the target execution time prediction function is obtained, including: iterating the cost function according to the historical execution time data and the historical capacity data, and obtaining the candidate execution time prediction function when the value of the cost function is less than the target value as the target execution time prediction function.

[0136] Optionally, determining, according to the historical database table, a candidate execution time-consuming prediction function corresponding to the target SQL statement includes:

[0137] According to the historical database table, obtaining the to-be-determined parameters of the candidate execution time-consuming prediction function;

[0138] Determine the candidate execution time-consuming prediction function according to the parameters to be determined;

[0139] The constructing the cost function according to the candidate execution time-consuming prediction function and the mapping relationship includes:

[0140] Determine a Euclidean distance error function between the candidate execution time prediction function and the mapping relationship according to the candidate execution time prediction function and the mapping relationship;

[0141] The Euclidean distance error function is used as the cost function.

[0142] Optionally, iterating the cost function according to the historical execution time consumption data and the historical capacity data to obtain the candidate execution time consumption prediction function when the value of the cost function is less than the target value as the target execution time consumption prediction function includes:

[0143] The Euclidean distance error function is iterated for the parameter to be determined, and the candidate execution time prediction function is obtained when the value of the Euclidean distance error function is less than the target value, and is used as the target execution time prediction function.

[0144] Optionally, the historical capacity data obtaining unit 201 is specifically configured to obtain the historical capacity data of the historical database table in different time intervals.

[0145] Optionally, the historical execution time consumption data obtaining unit 202 is specifically configured to obtain the historical execution time consumption data of the target SQL statement in different time intervals in the historical database table.

[0146] Optionally, obtaining the historical execution time-consuming data of the target SQL statement in different time intervals in the historical database table includes:

[0147] Obtain multiple historical execution time-consuming data of the target SQL statement in different time intervals in the historical database table;

[0148] The average of multiple historical execution time-consuming data of the target SQL statement in the different time intervals in the historical database table is used as the historical execution time-consuming data of the target SQL statement in the different time intervals in the historical database table.

[0149] Third embodiment

[0150] Corresponding to the SQL statement processing method provided in the first embodiment of the present application, the third embodiment of the present application further provides an electronic device. Since the device embodiment is basically similar to the first embodiment of the present application, the description is relatively simple, and the relevant parts refer to the partial description of the first embodiment of the present application. The device embodiment described below is only illustrative.

[0151] Please refer to Figure 3 , which is a schematic diagram of an electronic device provided in the second embodiment of the present application.

[0152] The electronic device comprises:

[0153] Processor 301; and

[0154] The memory 302 is used to store the program for the SQL statement processing method. After the device is powered on and the program for the SQL statement processing method is run by the processor, the following steps are performed:

[0155] Obtain historical capacity data of the historical database table associated with the target SQL statement;

[0156] Obtaining historical execution time consumption data of the target SQL statement when the historical database table corresponds to the historical capacity data;

[0157] Obtaining a target execution time prediction function corresponding to the target SQL statement according to the historical execution time data and the historical capacity data;

[0158] The target capacity data of the target associated database table is input into the target execution time consumption prediction function to obtain the target execution time consumption data of the target SQL statement.

[0159] It should be noted that the detailed description of the electronic device provided in the third embodiment of the present application can refer to the relevant description of the SQL statement processing method provided in the first embodiment of the present application, which will not be repeated here.

[0160] Fourth embodiment

[0161] Corresponding to the SQL statement processing method provided in the first embodiment of the present application, the fourth embodiment of the present application further provides a storage medium. Since the device embodiment is basically similar to the first embodiment of the present application, the description is relatively simple, and the relevant parts refer to the partial description of the first embodiment of the present application. The device embodiment described below is only illustrative.

[0162] The storage medium stores the program of the SQL statement processing method, and the program is executed by the processor to perform the following steps:

[0163] Obtain historical capacity data of the historical database table associated with the target SQL statement;

[0164] Obtain the historical execution time data of the target SQL statement corresponding to the historical capacity data in the historical database table;

[0165] According to the historical execution time consumption data and historical capacity data, the target execution time consumption prediction function corresponding to the target SQL statement is obtained;

[0166] The target capacity data of the target associated database table is input into the target execution time consumption prediction function to obtain the target execution time consumption data of the target SQL statement.

[0167] It should be noted that the detailed description of the electronic device provided in the fourth embodiment of the present application can refer to the relevant description of the SQL statement processing method provided in the first embodiment of the present application, which will not be repeated here.

[0168] Fifth embodiment

[0169] Corresponding to the SQL statement processing method provided in the first embodiment of the present application, the fifth embodiment of the present application also provides another SQL statement processing method. Since the fifth embodiment is basically similar to the first embodiment of the present application, the description is relatively simple, and the relevant parts can be referred to the partial description of the first embodiment of the present application. The fifth embodiment described below is only illustrative.

[0170] Please refer to Figure 4 , which is a flowchart of a SQL statement processing method provided in the fifth embodiment of the present application.

[0171] Step S401: obtaining a query request message sent by a user terminal for a target SQL statement.

[0172] In the fifth embodiment of the present application, the target SQL statement is a statement used to perform data management operations such as accessing, querying, inserting, updating, and deleting data in a database table.

[0173] The so-called database is a data set that organizes, stores and manages data according to a data structure. The so-called data includes company operation data, application running programs, web browsing data, personal consumption data, etc. In the fifth embodiment of the present application, the so-called data can be continuous values, such as sound, image, etc., or discrete values, such as symbols and text. The so-called database table is a file in the database that stores and manages data in a tabular form.

[0174] The so-called user terminal is a computing device installed with the application or software of the SQL statement processing method provided by the present application, such as a smart phone, a tablet computer, etc.

[0175] Step S402: Obtain historical capacity data of the historical database table associated with the target SQL statement in response to the query request message.

[0176] In the fifth embodiment of the present application, the so-called historical database table is a database table associated with the target SQL statement in a specified historical time interval, and the so-called historical capacity data of the historical database table is the amount of data stored in the historical database table in the specified historical time interval.

[0177] Step S403: Obtain historical execution time consumption data of the target SQL statement when the historical database table corresponds to historical capacity data.

[0178] The so-called historical execution time consumption data refers to the time consumption data when the target SQL statement performs operations such as access, query, insert, update and delete on the data in the historical database table.

[0179] Step S404: Obtain a target execution time prediction function corresponding to the target SQL statement according to the historical execution time data and the historical capacity data.

[0180] The so-called target execution time consumption prediction function is generally a prediction function used to predict the execution time consumption data of the target SQL statement when the associated database table corresponds to the specified capacity data.

[0181] Step S405: input the target capacity data of the target associated database table into the target execution time consumption prediction function to obtain the target execution time consumption data of the target SQL statement.

[0182] The target capacity data is input into the target execution time prediction function, and when the target associated database table corresponds to the target capacity data, the target execution time data is obtained, and the target associated database table is the target database table associated with the target SQL statement.

[0183] Step S406: Provide the target execution time consumption data to the user terminal.

[0184] Corresponding to the SQL statement processing method provided in the first embodiment of the present application, the sixth embodiment of the present application also provides another SQL statement processing method. Since the sixth embodiment is basically similar to the first embodiment of the present application, the description is relatively simple, and the relevant parts refer to the partial description of the first embodiment of the present application. The sixth embodiment described below is only illustrative.

[0185] Please refer to Figure 5 , which is a flowchart of a SQL statement processing method provided in the sixth embodiment of the present application.

[0186] Step S501: obtaining a processing request message sent by a user terminal for a target SQL statement.

[0187] In the sixth embodiment of the present application, the target SQL statement is a statement used to perform data management operations such as accessing, querying, inserting, updating, and deleting data in a database table.

[0188] The so-called database is a data set that organizes, stores and manages data according to a data structure. The so-called data includes company operation data, application running programs, web browsing data, personal consumption data, etc. In the sixth embodiment of the present application, the so-called data can be continuous values, such as sound, image, etc., or discrete values, such as symbols and text. The so-called database table is a file in the database that stores and manages data in a tabular form.

[0189] The so-called user terminal is a computing device installed with the application or software of the SQL statement processing method provided by the present application, such as a smart phone, a tablet computer, etc.

[0190] Step S502: Obtain historical capacity data of the historical database table associated with the target SQL statement in response to the query request message.

[0191] In the sixth embodiment of the present application, the so-called historical database table is a database table associated with the target SQL statement in a specified historical time interval, and the so-called historical capacity data of the historical database table is the amount of data stored in the historical database table in the specified historical time interval.

[0192] Step S503: Obtain historical execution time consumption data of the target SQL statement when the historical database table corresponds to historical capacity data.

[0193] The so-called historical execution time consumption data refers to the time consumption data when the target SQL statement performs operations such as access, query, insert, update and delete on the data in the historical database table.

[0194] Step S504: Obtain a target execution time prediction function corresponding to the target SQL statement according to the historical execution time data and the historical capacity data.

[0195] The so-called target execution time consumption prediction function is generally a prediction function used to predict the execution time consumption data of the target SQL statement when the associated database table corresponds to the specified capacity data.

[0196] Step S505: input the target capacity data of the target associated database table into the target execution time consumption prediction function to obtain the target execution time consumption data of the target SQL statement.

[0197] The target capacity data is input into the target execution time prediction function, and when the target associated database table corresponds to the target capacity data, the target execution time data is obtained, and the target associated database table is the target database table associated with the target SQL statement.

[0198] Step S506: obtaining the time point when the target execution time consumption data reaches the execution time consumption threshold, and before the time point, deleting duplicate data in the target associated database table.

[0199] Although the present application is disclosed as above in the preferred embodiment, it is not intended to limit the present application. Any technical personnel in this field may make possible changes and modifications without departing from the spirit and scope of the present invention. Therefore, the scope of protection of the present application shall be based on the scope defined by the claims of the present application.

[0200] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0201] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0202] 1. Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined in this article, computer-readable media does not include non-transitory media such as modulated data signals and carrier waves.

[0203] 2. Those skilled in the art should understand that the embodiments of the present application can be provided as methods, systems or computer program products. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

Claims

1. A method for processing SQL statements, characterized in that: include: Obtain historical capacity data of the historical database table associated with the target SQL statement; Obtaining historical execution time consumption data of the target SQL statement when the historical database table corresponds to the historical capacity data; Obtaining a target execution time prediction function corresponding to the target SQL statement according to the historical execution time data and the historical capacity data; Inputting the target capacity data of the target associated database table into the target execution time prediction function to obtain the target execution time data of the target SQL statement; Obtaining the time point when the target execution time data reaches the execution time threshold; When the target execution time consumption data reaches the time consumption threshold, it is predicted that the target SQL statement becomes a slow SQL statement, and the target SQL statement is processed.

2. The SQL statement processing method according to claim 1, characterized in that: The target execution time consumption prediction function is used to predict the execution time consumption data of the target SQL statement when the associated database table corresponds to the specified capacity data; The step of inputting the target capacity data of the target associated database table into the target execution time prediction function to obtain the target execution time data of the target SQL statement includes: inputting the target capacity data into the target execution time prediction function, and obtaining the target execution time data when the target associated database table corresponds to the target capacity data, wherein the target associated database table is a target database table associated with the target SQL statement.

3. The SQL statement processing method according to claim 2, characterized in that: The target execution time prediction function is used to predict the capacity data of the database table associated with the target SQL statement when the database table associated with the target SQL statement corresponds to the specified execution time data; The SQL statement processing method further includes: inputting the preset execution time consumption data of the target associated database table into the target execution time consumption prediction function, and obtaining the predicted capacity data of the target associated database table when the target associated database table corresponds to the preset execution time consumption data.

4. The SQL statement processing method according to claim 1, characterized in that: Also includes: Display at least one of the target execution time-consuming data and the time point.

5. The SQL statement processing method according to claim 1, characterized in that: Also includes: Obtaining an execution time-consuming query request message sent by a user terminal for the target SQL statement; In response to the execution time query request message, at least one of the target execution time data and the time point is provided to the user terminal.

6. The SQL statement processing method according to claim 1, characterized in that: The step of obtaining a target execution time prediction function corresponding to the target SQL statement according to the historical execution time data and the historical capacity data includes: Constructing a cost function for obtaining the target execution time prediction function according to the historical execution time data and the historical capacity data; When the value of the cost function is less than the target value, the target execution time prediction function is obtained.

7. The SQL statement processing method according to claim 6, characterized in that: The constructing, according to the historical execution time consumption data and the historical capacity data, a cost function for obtaining the target execution time consumption prediction function comprises: Determine, according to the historical database table, a candidate execution time-consuming prediction function corresponding to the target SQL statement; Determine a mapping relationship between the historical execution time consumption data and the historical capacity data according to the historical execution time consumption data and the historical capacity data; The cost function is constructed according to the candidate execution time-consuming prediction function and the mapping relationship.

8. The SQL statement processing method according to claim 7, characterized in that: When the value of the cost function is less than the target value, the target execution time prediction function is obtained, including: iterating the cost function according to the historical execution time data and the historical capacity data, and obtaining the candidate execution time prediction function when the value of the cost function is less than the target value as the target execution time prediction function.

9. The SQL statement processing method according to claim 8, characterized in that: The step of determining, according to the historical database table, a candidate execution time-consuming prediction function corresponding to the target SQL statement includes: According to the historical database table, obtaining the to-be-determined parameters of the candidate execution time-consuming prediction function; Determine the candidate execution time-consuming prediction function according to the to-be-determined parameter; The constructing the cost function according to the candidate execution time-consuming prediction function and the mapping relationship includes: Determine a Euclidean distance error function between the candidate execution time prediction function and the mapping relationship according to the candidate execution time prediction function and the mapping relationship; The Euclidean distance error function is used as the cost function.

10. The SQL statement processing method according to claim 8, characterized in that: The step of iterating the cost function according to the historical execution time consumption data and the historical capacity data to obtain the candidate execution time consumption prediction function when the value of the cost function is less than the target value as the target execution time consumption prediction function includes: For the parameters to be determined of the candidate execution time prediction function, the Euclidean distance error function between the candidate execution time prediction function and the mapping relationship between the historical execution time data and the historical capacity data is iterated to obtain the candidate execution time prediction function when the value of the Euclidean distance error function is less than the target value, as the target execution time prediction function.

11. The SQL statement processing method according to claim 1, characterized in that: The obtaining of historical capacity data of a historical database table associated with a target SQL statement includes: obtaining the historical capacity data of the historical database table in different time intervals.

12. The SQL statement processing method according to claim 11, characterized in that: The obtaining of the historical execution time-consuming data of the target SQL statement when the historical database table corresponds to the historical capacity data includes: obtaining the historical execution time-consuming data of the target SQL statement in different time intervals in the historical database table.

13. The SQL statement processing method according to claim 12, characterized in that: The obtaining of the historical execution time-consuming data of the target SQL statement in different time intervals in the historical database table includes: Obtain multiple historical execution time-consuming data of the target SQL statement in different time intervals in the historical database table; The average of multiple historical execution time-consuming data of the target SQL statement in the different time intervals in the historical database table is used as the historical execution time-consuming data of the target SQL statement in the different time intervals in the historical database table.

14. A SQL statement processing device, characterized in that: include: A historical capacity data acquisition unit, used to acquire historical capacity data of a historical database table associated with a target SQL statement; A historical execution time consumption data obtaining unit, used for obtaining the historical execution time consumption data of the target SQL statement when the historical database table corresponds to the historical capacity data; A target execution time consumption prediction function obtaining unit, used for obtaining a target execution time consumption prediction function corresponding to the target SQL statement according to the historical execution time consumption data and the historical capacity data; A target execution time consumption data obtaining unit, used for inputting the target capacity data of the target associated database table into the target execution time consumption prediction function to obtain the target execution time consumption data of the target SQL statement; Obtaining the time point when the target execution time data reaches the execution time threshold; When the target execution time consumption data reaches the time consumption threshold, it is predicted that the target SQL statement becomes a slow SQL statement, and the target SQL statement is processed.

15. An electronic device, characterized in that: include: processor; as well as The memory is used to store a program for the SQL statement processing method. After the device is powered on and the program for the SQL statement processing method is run by the processor, the following steps are performed: Obtain historical capacity data of the historical database table associated with the target SQL statement; Obtaining historical execution time consumption data of the target SQL statement when the historical database table corresponds to the historical capacity data; Obtaining a target execution time prediction function corresponding to the target SQL statement according to the historical execution time data and the historical capacity data; Inputting the target capacity data of the target associated database table into the target execution time prediction function to obtain the target execution time data of the target SQL statement; Obtaining the time point when the target execution time data reaches the execution time threshold; When the target execution time consumption data reaches the time consumption threshold, it is predicted that the target SQL statement becomes a slow SQL statement, and the target SQL statement is processed.

16. A storage medium, characterized in that: A program for a SQL statement processing method is stored, and the program is executed by a processor to perform the following steps: Obtain historical capacity data of the historical database table associated with the target SQL statement; Obtaining historical execution time consumption data of the target SQL statement when the historical database table corresponds to the historical capacity data; Obtaining a target execution time prediction function corresponding to the target SQL statement according to the historical execution time data and the historical capacity data; Inputting the target capacity data of the target associated database table into the target execution time prediction function to obtain the target execution time data of the target SQL statement; Obtaining the time point when the target execution time data reaches the execution time threshold; When the target execution time consumption data reaches the time consumption threshold, it is predicted that the target SQL statement becomes a slow SQL statement, and the target SQL statement is processed.

17. A method for processing SQL statements, characterized in that: include: Obtaining a query request message sent by a user terminal for a target SQL statement; In response to the query request message, obtaining historical capacity data of the historical database table associated with the target SQL statement; Obtaining historical execution time consumption data of the target SQL statement when the historical database table corresponds to the historical capacity data; Obtaining a target execution time prediction function corresponding to the target SQL statement according to the historical execution time data and the historical capacity data; Inputting the target capacity data of the target associated database table into the target execution time prediction function to obtain the target execution time data of the target SQL statement; Obtaining the time point when the target execution time data reaches the execution time threshold; When the target execution time consumption data reaches the time consumption threshold, predict that the target SQL statement becomes a slow SQL statement, and process the target SQL statement; The target execution time consumption data is provided to the user terminal.

18. A method for processing SQL statements, characterized in that: include: Obtaining a processing request message sent by a user terminal for a target SQL statement; In response to the query request message, obtaining historical capacity data of the historical database table associated with the target SQL statement; Obtaining historical execution time consumption data of the target SQL statement when the historical database table corresponds to the historical capacity data; Obtaining a target execution time prediction function corresponding to the target SQL statement according to the historical execution time data and the historical capacity data; Input the target capacity data of the target associated database table into the target execution time prediction function to obtain the target execution time data of the target SQL statement: Obtain the time point when the target execution time data reaches the execution time threshold, and delete the duplicate data in the target associated database table before the time point; when the target execution time data reaches the time threshold, predict that the target SQL statement becomes a slow SQL statement, and process the target SQL statement.

Citation Information

Patent Citations

  • Method and device for discovering low performance structural query language (SQL) statements, and method and device for forecasting SQL statement performance

    CN104820663A

  • Regression-based cost modeling method and device for predicting SQL statement performance

    CN104834634A