SQL (Structured Query Language) capacity water level detection method and device and electronic equipment

By obtaining the log information of the target database and SQL execution under set conditions, the problem of water level threshold detection of a single SQL capacity is solved, ensuring the stable operation of the database and improving detection efficiency and accuracy.

CN120296029APending Publication Date: 2025-07-11DUXIAOMAN TECH (BEIJING) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510348591.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-24
Publication Date
2025-07-11

AI Technical Summary

Technical Problem

The existing technology lacks a capacity water level threshold detection scheme for a single SQL, resulting in unstable database operation.

Method used

By obtaining the log information of the target database, determining the QPS mean of multiple SQLs, and performing SQL during the low peak period of the business, combining the thread concurrency threshold and the response time threshold, multiple capacity water level detections are performed to obtain the capacity water level threshold of a single SQL.

Benefits of technology

The capacity water level threshold detection of a single SQL is realized, which ensures the stable operation of the database and improves detection efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120296029A_ABST
    Figure CN120296029A_ABST
Patent Text Reader

Abstract

The invention provides an SQL (Structured Query Language) capacity water level detection method and device and electronic equipment, and relates to the technical field of databases. The method comprises the following steps: acquiring log information of a target database in response to a capacity water level detection request for a first SQL (Structured Query Language); the log information comprises SQL execution conditions corresponding to a plurality of SQL executed in the target database; first QPS mean values corresponding to the multiple SQL are determined based on the log information; executing the multiple SQL in a target database according to the obtained multiple first QPS mean values, and performing capacity water level detection on the first SQL in the execution process of the multiple SQL to obtain a capacity water level threshold value of the first SQL; the capacity water level threshold represents the maximum QPS when the first SQL is executed in the target database. Therefore, the capacity water level threshold value of the single SQL can be detected.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of database technology, and in particular, to a method, apparatus, and electronic device for detecting the capacity water level of SQL. Background Art

[0002] Before a structured query language (SQL) goes online, detecting the maximum capacity of the SQL in the database, and after detecting the capacity water level threshold corresponding to the SQL, limiting the concurrent execution number of the SQL within this capacity water level threshold can ensure the stable and smooth operation of the entire database. However, there are usually multiple types of SQLs executed in a database. The prior art is limited to monitoring and controlling the capacity water level of the entire database, that is, detecting the execution threshold of all types of SQLs in the database as a whole, and there is no water level detection scheme for a single SQL.

[0003] In view of this, how to detect the capacity water level threshold for a single SQL is an urgent problem to be solved currently. Summary of the Invention

[0004] Embodiments of this application provide a method, apparatus, and electronic device for detecting the capacity water level of SQL, so as to detect the capacity water level threshold for a single SQL.

[0005] In a first aspect, embodiments of this application provide a method for detecting the capacity water level of SQL, and the method includes:

[0006] In response to a request for detecting the capacity water level of a first SQL, obtaining log information of a target database; the log information includes: SQL execution situations respectively corresponding to multiple SQLs executed in the target database;

[0007] Determining first mean values of queries per second (QPS) respectively corresponding to the multiple SQLs based on the log information;

[0008] Executing the multiple SQLs in the target database according to the obtained first QPS mean values, and detecting the capacity water level of the first SQL during the execution of the multiple SQLs, to obtain a capacity water level threshold of the first SQL; the capacity water level threshold represents: the maximum QPS when the first SQL is executed in the target database.

[0009] In an optional embodiment, executing the multiple SQLs in the target database according to the obtained first QPS mean values includes:

[0010] Determine the business off-peak period of the target database based on log information; the business off-peak period is a time period during which the resources occupied by the business are less than the set resource occupancy threshold and the continuous duration is greater than the set continuous duration threshold;

[0011] During the business off-peak period, execute multiple SQLs in the target database according to multiple first QPS means.

[0012] In an alternative embodiment, during the execution of multiple SQLs, perform capacity water level detection on the first SQL to obtain the capacity water level threshold of the first SQL, including:

[0013] Based on the preset detection duration and the set thread concurrency threshold, perform multiple capacity water level detections on the first SQL to obtain multiple second QPS means;

[0014] Obtain the capacity water level threshold of the first SQL based on multiple second QPS means.

[0015] In an alternative embodiment, based on the preset detection duration and the set thread concurrency threshold, perform multiple capacity water level detections on the first SQL to obtain multiple second QPS means, including:

[0016] Determine the number of thread concurrency used when executing multiple SQLs in the target database, and based on the number of thread concurrency and the thread concurrency threshold, determine the maximum thread concurrency for executing the first SQL;

[0017] During the execution of the first SQL based on the maximum thread concurrency, perform multiple capacity water level detections on the first SQL according to the detection duration to obtain multiple second QPS means.

[0018] In an alternative embodiment, perform multiple capacity water level detections on the first SQL to obtain multiple second QPS means, including:

[0019] During each capacity water level detection of the first SQL, perform the following operations respectively:

[0020] When it is determined that the first execution average response time of the first SQL is less than or equal to the set execution average response time threshold, record the initial QPS corresponding to the first SQL;

[0021] Based on the initial QPS, perform multiple stress tests on the first SQL to obtain multiple second execution average response times;

[0022] Iteratively modify the initial QPS based on multiple second execution average response times until the target QPS that meets the preset execution average response time condition is obtained;

[0023] Take the target QPS as the second QPS average value obtained by detecting the capacity water level of the first SQL this time.

[0024] In an alternative embodiment, the preset execution average response time condition is that a continuous set number of second execution average response times all belong to the response time fluctuation range set for the first execution average response time.

[0025] In an alternative embodiment, the method further includes:

[0026] Calculate the hash value of the first SQL based on the statement information of the first SQL, and generate a first SQL fingerprint based on the hash value; the first SQL fingerprint is used to standardize and normalize the first SQL;

[0027] If there is a target SQL fingerprint in the SQL fingerprints of multiple SQLs that is the same as the first SQL fingerprint, then use the capacity water level threshold of the SQL corresponding to the target SQL fingerprint as the capacity water level threshold of the first SQL.

[0028] In an alternative embodiment, the method further includes:

[0029] If there is no target SQL fingerprint in the SQL fingerprints of multiple SQLs, then obtain the SQL costs corresponding to the multiple SQLs respectively; where each SQL cost represents the resource occupancy required to execute the corresponding SQL;

[0030] Based on the SQL cost similarity between the first SQL and the multiple SQLs respectively, screen out the target SQLs from the multiple SQLs whose SQL costs meet the preset SQL cost similarity conditions with the first SQL;

[0031] Use the capacity water level threshold of the target SQL as the capacity water level threshold of the first SQL.

[0032] In a second aspect, an embodiment of the present application further provides a capacity water level detection device for SQLs, and the device includes:

[0033] An acquisition module, configured to acquire log information of a target database in response to a capacity water level detection request for a first SQL; the log information includes: the SQL execution conditions corresponding to multiple SQLs executed in the target database;

[0034] A determination module, configured to determine the first QPS average value corresponding to each of the multiple SQLs based on the log information;

[0035] A detection module is used to execute multiple SQL statements in a target database according to multiple obtained first QPS means, and perform capacity water level detection on the first SQL during the execution of the multiple SQL statements to obtain a capacity water level threshold for the first SQL; the capacity water level threshold represents the maximum QPS when executing the first SQL in the target database.

[0036] In an alternative embodiment, when executing multiple SQL statements in the target database according to the multiple obtained first QPS means, the detection module is specifically configured to:

[0037] Determine the business low peak period of the target database based on log information; the business low peak period is a time period during which the resources occupied by the business are less than a set resource occupancy threshold and the continuous duration is greater than a set continuous duration threshold;

[0038] During the business low peak period, execute multiple SQL statements in the target database according to the multiple first QPS means.

[0039] In an alternative embodiment, when performing capacity water level detection on the first SQL during the execution of the multiple SQL statements to obtain a capacity water level threshold for the first SQL, the detection module is specifically configured to:

[0040] Perform multiple capacity water level detections on the first SQL based on a preset detection duration and a set thread concurrency threshold to obtain multiple second QPS means;

[0041] Obtain the capacity water level threshold for the first SQL based on the multiple second QPS means.

[0042] In an alternative embodiment, when performing multiple capacity water level detections on the first SQL based on a preset detection duration and a set thread concurrency threshold to obtain multiple second QPS means, the detection module is specifically configured to:

[0043] Determine the number of thread concurrencies used when executing multiple SQL statements in the target database, and determine the maximum thread concurrency for executing the first SQL based on the number of thread concurrencies and the thread concurrency threshold;

[0044] During the execution of the first SQL based on the maximum thread concurrency, perform multiple capacity water level detections on the first SQL according to the detection duration to obtain multiple second QPS means.

[0045] In an alternative embodiment, when performing multiple capacity water level detections on the first SQL to obtain multiple second QPS means, the detection module is specifically configured to:

[0046] During each process of performing capacity water level detection on the first SQL, perform the following operations respectively:

[0047] When it is determined that the first execution average response time of the first SQL is less than or equal to the set execution average response time threshold, record the initial QPS corresponding to the first SQL;

[0048] Based on the initial QPS, perform multiple stress tests on the first SQL to obtain multiple second execution average response times;

[0049] Based on the multiple second execution average response times, iteratively modify the initial QPS until a target QPS that meets the preset execution average response time condition is obtained;

[0050] Use the target QPS as the second QPS average value obtained by detecting the capacity water level of the first SQL this time.

[0051] In an alternative embodiment, the detection module is further configured to:

[0052] Calculate the hash value of the first SQL based on the statement information of the first SQL, and generate the first SQL fingerprint based on the hash value; the first SQL fingerprint is used to perform standardization and normalization processing on the first SQL;

[0053] If there is a target SQL fingerprint in the SQL fingerprints of multiple SQLs that is the same as the first SQL fingerprint, use the capacity water level threshold of the SQL corresponding to the target SQL fingerprint as the capacity water level threshold of the first SQL.

[0054] In an alternative embodiment, the detection module is further configured to:

[0055] If there is no target SQL fingerprint in the SQL fingerprints of multiple SQLs, obtain the SQL costs corresponding to the multiple SQLs respectively; where each SQL cost represents the resource occupancy required to execute the corresponding SQL;

[0056] Based on the SQL cost similarity between the first SQL and multiple SQLs respectively, screen out the target SQL from the multiple SQLs whose SQL cost with the first SQL meets the preset SQL cost similarity condition;

[0057] Use the capacity water level threshold of the target SQL as the capacity water level threshold of the first SQL.

[0058] In a third aspect, an embodiment of the present application further provides an electronic device, including:

[0059] A processor; and

[0060] A memory storing a program,

[0061] where the program includes instructions that, when executed by the processor, cause the processor to execute the method for detecting the capacity water level of SQL as described in the first aspect.

[0062] Fourthly, an embodiment of the present application further provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause a computer to execute the SQL capacity water level detection method as described in the first aspect.

[0063] Fifthly, the present application provides a computer program product, which, when called by a computer, causes the computer to execute the steps of the SQL capacity water level detection method as described in the first aspect.

[0064] The beneficial effects of the present application are as follows:

[0065] In the SQL capacity water level detection method provided by the embodiment of the present application, once a capacity water level detection request for the first SQL is received, the log information of the target database can be obtained, and then according to the SQL execution conditions respectively corresponding to the multiple SQLs executed in the target database included in the log information, the first QPS average values respectively corresponding to the multiple SQLs are determined. Furthermore, during the process of executing the multiple SQLs in the target database according to the multiple first QPSs, the capacity water level of the first SQL is detected to obtain the capacity water level threshold of the first SQL, realizing the detection of the capacity water level threshold of a single SQL.

[0066] In addition, other features and advantages of the present application will be described in the subsequent description, and some of them will become obvious from the description, or be understood by implementing the present application. The objectives and other advantages of the present application can be achieved and obtained through the structures specifically pointed out in the written description, claims, and drawings. Description of the Drawings

[0067] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the drawings described herein are used to provide a further understanding of the present application, form a part of the present application, and do not constitute an improper limitation of the present application. In the drawings:

[0068] Figure 1 It is a schematic diagram of an optional system architecture applicable to the embodiment of the present application;

[0069] Figure 2 It is a schematic diagram of the implementation process of a SQL capacity water level detection method provided by the embodiment of the present application;

[0070] Figure 3 It is a logical schematic diagram of a SQL capacity water level detection provided by the embodiment of the present application;

[0071] Figure 4 It is a schematic diagram of the specific method process of a SQL capacity water level detection provided by the embodiment of the present application;

[0072] Figure 5 A schematic diagram of a specific scenario for determining the capacity water level threshold of SQL provided by an embodiment of the present application;

[0073] Figure 6 Another schematic diagram of a specific scenario for determining the capacity water level threshold of SQL provided by an embodiment of the present application;

[0074] Figure 7 A schematic diagram of the structure of a capacity water level detection device for SQL provided by an embodiment of the present application;

[0075] Figure 8 A schematic diagram of the structure of an electronic device provided by an embodiment of the present application. Detailed implementation manners

[0076] The embodiments of the present application will be described in more detail with reference to the accompanying drawings. Although some embodiments of the present application are shown in the drawings, it should be understood that the present application can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Instead, these embodiments are provided to more thoroughly and completely understand the present application. It should be understood that the drawings and embodiments of the present application are only for exemplary purposes and are not used to limit the protection scope of the present application.

[0077] It should be understood that the various steps recorded in the method embodiments of the present application can be executed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present application is not limited in this regard.

[0078] The term "including" and its variants used herein are open-ended, that is, "including but not limited to". The term "based on" is "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description. It should be noted that the concepts such as "first" and "second" mentioned in the present application are only used to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependent relationships.

[0079] It should be noted that the modifications of "one" and "multiple" mentioned in the present application are illustrative rather than restrictive. Those skilled in the art should understand that unless otherwise clearly specified in the context, it should be understood as "one or more".

[0080] The names of the messages or information exchanged between multiple devices in the embodiments of the present application are only for illustrative purposes and do not limit the scope of these messages or information.

[0081] The following explains some terms in the embodiments of the present application to facilitate understanding by those skilled in the art.

[0082] (1) Database capacity water level: It refers to the proportional relationship between the storage space already used by the database and the total storage space. It is an important indicator to measure the usage of database storage resources, often presented in the form of a percentage, and is used to help database administrators monitor and manage the storage status of the database.

[0083] (2) QPS: It refers to the number of query operations executed by the database per second and is an important indicator to measure the processing ability and performance of the database.

[0084] (3) Number of concurrent program executions: That is, the number of concurrent SQL executions by the program. The program can concurrently initiate connections to the database and execute SQL at the same time. The larger the number of concurrent program executions, the more SQL statements will be executed concurrently.

[0085] (4) Threads_Running metric: It is a system variable that can be used to represent the number of currently running threads and can reflect the number of threads actively executing in the current database (such as, MySQL database), including connection threads for processing client requests, background task threads, etc.

[0086] (5) SQL fingerprint: It is a unique identifier obtained after standardizing an SQL statement. By removing some variable factors in the SQL statement (such as, specific parameter values, spaces, case, etc.), SQL statements with the same logical structure are converted into a unified pattern, thus facilitating the classification, statistics, and analysis of SQL statements. Exemplarily, "select a from b where c=d" and "select a from b where c=e" belong to the same SQL fingerprint.

[0087] (6) SQL Cost: Usually refers to the resource consumption and overhead required to execute a certain SQL query or operation. In database query optimization, SQL Cost is one of the important indicators for evaluating and comparing the efficiency of different execution plans.

[0088] (7) Execution average response time: Abbreviated as execution average response value, it is a key indicator to measure the response speed of a system, service, or operation when processing requests, representing the average time spent by the system processing each request within a certain time range.

[0089] (8) SQL stress testing: That is, to conduct stress testing on SQL statements or database systems, aiming to evaluate the performance, stability, and reliability of the database in processing SQL requests under different load conditions, discover potential problems, and provide a basis for optimization.

[0090] Based on the above nouns and related term explanations, the design concept of the embodiments of the present application is briefly introduced below:

[0091] The database capacity water level is an important indicator affecting the stable operation of the database. Once the capacity water level exceeds the limit, slow queries and other situations may occur, thus affecting business operations. Therefore, the height of the water level should be monitored in real time. Before the SQL goes online, detect the maximum capacity of the SQL in this database. After detecting the capacity water level threshold corresponding to this SQL, limit the concurrent execution number of this SQL within this capacity water level threshold, which can ensure the stable and smooth operation of the entire database.

[0092] However, there are usually thousands of SQLs executed in a database. The prior art is limited to monitoring and controlling the capacity water level of the entire database, that is, detecting the execution threshold of all types of SQLs in the database as a whole, and there is no water level detection scheme for a single SQL.

[0093] In view of this, in order to improve or solve the above problems and achieve the detection of the capacity water level threshold for a single SQL. The embodiments of the present application provide a method for detecting the capacity water level for a single SQL, which may specifically include: in response to a request for detecting the capacity water level of the first SQL, obtaining the log information of the target database; the log information may include: the SQL execution situations corresponding to multiple SQLs executed in the target database; then, determining the first average QPS corresponding to each of the multiple SQLs based on the log information; finally, executing the multiple SQLs in the target database according to the obtained multiple first average QPSs, and detecting the capacity water level of the first SQL during the execution of the multiple SQLs to obtain the capacity water level threshold of the first SQL; the capacity water level threshold may represent: the maximum QPS when the first SQL is executed in the target database.

[0094] In particular, the preferred embodiments of the present application are described below with reference to the accompanying drawings of the specification. It should be understood that the preferred embodiments described here are only used to illustrate and explain the present application and are not used to limit the present application. And, without conflict, the embodiments of the present application and the features in the embodiments may be combined with each other.

[0095] Refer to Figure 1As shown, it is a schematic diagram of an optional system architecture applicable to the embodiments of the present application. The system architecture may include: terminal devices (101a, 101b) and a server 102. Information interaction can be carried out between the terminal devices (101a, 101b) and the server 102 through a communication network. Among them, the communication methods adopted by the aforementioned communication network may include: wireless communication methods and wired communication methods.

[0096] Exemplarily, the terminal devices (101a, 101b) can access the network through cellular mobile communication technology and communicate with the server 102. Among them, the cellular mobile communication technology, for example, includes fifth-generation mobile networks (5G) technology or next-generation mobile communication technology. Optionally, the terminal devices (101a, 101b) can access the network through short-range wireless communication methods and communicate with the server 102. Among them, the short-range wireless communication methods, for example, include wireless fidelity (Wi-Fi) technology.

[0097] The embodiments of the present application do not impose any restrictions on the number of communication devices involved in the above system architecture. For example, the above system architecture may include more terminal devices, or fewer terminal devices, or other network devices. As Figure 1 shown, only the terminal devices (101a, 101b) and the server 102 are taken as examples for description. Below, a brief introduction to the above-mentioned various communication devices and their respective functions is given.

[0098] The terminal devices (101a, 101b) are devices that can provide voice and / or data connectivity to users and can be devices that support wired and / or wireless connection methods.

[0099] Exemplarily, the terminal devices (101a, 101b) may include, but are not limited to: mobile phones, tablet computers, laptop computers, palmtop computers, mobile internet devices (MIDs), wearable devices, virtual reality (VR) devices, augmented reality (AR) devices, wireless terminal devices in industrial control, wireless terminal devices in unmanned driving, wireless terminal devices in smart grids, wireless terminal devices in transportation safety, wireless terminal devices in smart cities, or wireless terminal devices in smart homes, etc.

[0100] In addition, relevant clients can be installed on the terminal devices (101a, 101b). The client can be software, such as an application (APP), a browser, a short video software, etc., or it can be a web page, a mini-program, etc. It should be noted that the terminal devices (101a, 101b) in the embodiments of the present application can enable the above-mentioned clients related to the capacity water level detection of SQL to send a capacity water level detection request for the first SQL (or target SQL) to the server 102, so as to perform subsequent method steps such as the capacity water level detection for the first SQL (or target SQL).

[0101] The server 102 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery network (CDN), and big data and artificial intelligence platforms.

[0102] It is worth noting that in the embodiments of the present application, the server 102 can be used to respond to a capacity water level detection request for the first SQL, and obtain the log information of the target database; the log information can include: the SQL execution situations respectively corresponding to multiple SQLs executed in the target database; then, based on the log information, determine the first QPS average values respectively corresponding to the multiple SQLs; finally, execute the multiple SQLs in the target database according to the obtained multiple first QPS average values, and perform a capacity water level detection on the first SQL during the execution of the multiple SQLs to obtain the capacity water level threshold of the first SQL; the capacity water level threshold can represent: the maximum QPS when the first SQL is executed in the target database.

[0103] Next, in combination with the above system architecture and with reference to the accompanying drawings, the method for detecting the capacity water level of SQL provided by the exemplary embodiments of the present application will be described. It should be noted that the above system architecture is only shown for the convenience of understanding the spirit and principle of the present application, and the embodiments of the present application are not limited in this regard.

[0104] Refer to Figure 2 As shown, it is a schematic diagram of the implementation process of a method for detecting the capacity water level of SQL provided by the embodiments of the present application. Taking the server as an example of the execution subject, the specific implementation process of the method is as follows:

[0105] S201: Respond to a capacity water level detection request for the first SQL, and obtain the log information of the target database.

[0106] The above log information may include: the SQL execution status corresponding to multiple SQLs executed in the target database. Optionally, the above log information may be binlog, and of course, the above log information may also be other types of logs, which are not specifically limited in the embodiments of the present application.

[0107] By obtaining the log information of the target database, it is possible to determine multiple SQLs routinely executed in the target database and the daily QPS value corresponding to each SQL. In this way, taking these SQLs as the basic traffic and replaying according to the daily QPS value corresponding to each SQL can improve the accuracy of subsequent capacity water level detection for the first SQL.

[0108] S202: Determine the first QPS average value corresponding to each of the multiple SQLs based on the log information.

[0109] Each of the above first QPS average values may be the QPS value of the corresponding SQL within a set time range (for example, 1 minute). Optionally, the calculation formula for the first QPS average value may be specifically expressed as follows:

[0110]

[0111] where QPS ave.1 represents the first QPS average value, T1 represents the above set time range, and S qps represents the total number of times the first SQL is executed within the set time range (i.e., T1).

[0112] S203: Execute multiple SQLs in the target database according to the obtained multiple first QPS average values, and perform capacity water level detection on the first SQL during the execution of the multiple SQLs to obtain the capacity water level threshold of the first SQL.

[0113] The above capacity water level threshold may characterize: the maximum QPS when the first SQL is executed in the target database. Once the capacity water level of the first SQL exceeds the capacity water level threshold of the first SQL when the first SQL is executed in the target database, the performance of the target database (or the first SQL) will be greatly affected.

[0114] Since the capacity water level detection of SQL usually takes a long time, the capacity water level of the first SQL can be detected during the off-peak period of the target database's business to improve the detection efficiency of the capacity water level threshold. Therefore, in an optional implementation, after the server obtains the first QPS average values corresponding to multiple SQLs respectively, it can determine the off-peak period of the target database based on the log information, and then execute multiple SQLs in the target database according to the multiple first QPS average values during the off-peak period. Among them, the off-peak period of the business is a time period in which the resources occupied by the business are less than the set resource occupancy threshold and the continuous duration is greater than the set continuous duration threshold. Exemplarily, assuming that the set resource occupancy threshold is 20% of the resources corresponding to the target database, and the aforementioned set continuous duration threshold is 2 minutes. If the resource occupancy ratio of the target database (i.e., the resources occupied by the business) is less than 20% when the target database executes the business within 4 minutes, it can be determined that these 4 minutes are the off-peak period of the business.

[0115] Furthermore, during the execution process of the server executing multiple SQLs in the target database according to the obtained multiple first QPS average values, the capacity water level of the first SQL can be detected, so as to obtain the capacity water level threshold of the first SQL.

[0116] When detecting the capacity water level threshold of the first SQL, it is necessary to execute the first SQL in the target database, and then take the maximum execution times of the first SQL within 1 second as the capacity water level threshold of the first SQL. However, the maximum execution times of the first SQL (i.e., the capacity water level threshold of the first SQL) are usually limited by the number of concurrent program executions and the Threads_Running indicator of the target database. Generally speaking, the larger the number of concurrent program executions, the higher the Threads_Running indicator will be. An overly high Threads_Running indicator will result in a large performance consumption of the target database, thus slowing down the response speed of the target database. Therefore, during the process of detecting the capacity water level of the first SQL, it is necessary to control the Threads_Running indicator. For example, the Threads_Running indicator is limited to within 50.

[0117] Therefore, in an optional implementation, when executing step S203, the server can perform multiple capacity water level detections on the first SQL based on a preset detection duration (such as 10 minutes) and a set thread concurrency threshold (such as 50), obtain multiple second QPS average values, and then obtain the capacity water level threshold of the first SQL based on the multiple second QPS average values. Optionally, the calculation formula for the capacity water level threshold of the aforementioned first SQL can be specifically expressed as follows:

[0118]

[0119] Among them, CWL th represents the capacity water level threshold of the first SQL, N represents the number of the second QPS means or the number of times of capacity water level detection of the first SQL, and QPS ave.2.i represents the i-th second QPS mean.

[0120] It should be noted that the total number of threads used when executing the above-mentioned multiple SQLs and the first SQL in the target database, that is, the Threads_Running metric of the target database, is not limited in this embodiment of the present application.

[0121] Refer to Figure 3 As shown, it is a logical schematic diagram of capacity water level detection of an SQL provided by an embodiment of the present application. The server can determine the number of concurrent threads used when executing the above-mentioned multiple SQLs (for example, 5 SQLs) in the target database, and based on the number of concurrent threads and the thread concurrency threshold, determine the maximum number of concurrent threads for executing the first SQL. Thus, during the process of executing the first SQL based on the maximum number of concurrent threads, the first SQL is subjected to multiple capacity water level detections according to the above-mentioned detection duration (for example, 10 minutes) to obtain multiple second QPS means.

[0122] Exemplarily, assuming that the number of concurrent threads used when executing the above-mentioned multiple SQLs in the target database is 20, and the above-set thread concurrency threshold is 50, then the server can determine that the maximum number of concurrent threads for executing the first SQL in the target database is 30. Therefore, the server can execute the first SQL in the target database according to the remaining 30 threads, and during the process of executing the first SQL, perform multiple capacity water level detections on the first SQL according to the above-mentioned detection duration to obtain multiple second QPS means, thereby realizing the capacity water level detection of the first SQL.

[0123] Based on the above method, on the basis of the basic traffic, that is, when executing the above-mentioned multiple SQLs in the target database, the first SQL can be executed concurrently. If the number of threads currently running in the target database (that is, the value of the Threads_Running metric) is less than the above-set thread concurrency threshold, the concurrent execution number of the first SQL can be continuously increased. If the number of threads currently running in the target database (that is, the value of the Threads_Running metric) is greater than the above-set thread concurrency threshold, the concurrent execution number can be reduced, and finally the Threads_Running is stabilized below the above-set thread concurrency threshold, approaching the state of the above-set thread concurrency threshold. Furthermore, when the Threads_Running is close to the above-set thread concurrency threshold, multiple capacity water level detections are performed on the first SQL.

[0124] In an alternative implementation, refer toFigure 4 As shown, during each capacity water level detection of the first SQL, the server can perform the following operations respectively:

[0125] S401: When it is determined that the first execution average response time of the first SQL is less than or equal to the set execution average response time threshold, record the initial QPS corresponding to the first SQL.

[0126] Exemplarily, if the above first execution average response time is denoted as: T ave,r1 , and the above set execution average response time threshold can be denoted as: T ave,th . Then, the fact that the first execution average response time of the first SQL is less than or equal to the set execution average response time threshold can be expressed as: T ave,r1 ≤T ave,th .

[0127] The fact that the first execution average response time of the first SQL is less than or equal to the set execution average response time threshold can be understood as that when the first SQL is executed in the target database, the performance of the target database exceeds the set performance threshold. In other words, the target database can provide better services at this time.

[0128] In addition, when the first execution average response time of the first SQL is less than or equal to the set execution average response time threshold, the above initial QPS and the first execution average response time can be used as reference values.

[0129] S402: Based on the initial QPS, perform multiple stress tests on the first SQL to obtain multiple second execution average response times.

[0130] Specifically, when executing step S402, after the server obtains the initial QPS, it can continuously send stress tests (i.e., pressure tests) for the first SQL to the target database according to the initial QPS, so as to obtain multiple second execution average response times. Among them, the i-th second execution average response time can be denoted as: T ave,r2,i .

[0131] S403: Based on multiple second execution average response times, iteratively modify the initial QPS until a target QPS that meets the preset execution average response time condition is obtained.

[0132] The above preset execution average response time condition can be: consecutive set numbers of second execution average response times all belong to the response time fluctuation range set for the first execution average response time. Exemplarily, the above consecutive set numbers can be: consecutive 5, and the above response time fluctuation range can be (0.9· ave,r1 , 1.1T ave,r1, that is, the second execution average response time belongs to the interval of plus or minus 10% of the first execution average response time.

[0133] Then, during the process of the server iteratively modifying the initial QPS based on the above-mentioned multiple second execution average response times, if in a certain modification of the initial QPS, five consecutive second execution average times all belong to the response time fluctuation interval (0.9T ave,r1 , 1.1T ave,r1 , it can be determined that the QPS obtained from this modification is used as the target QPS, and moreover, stop iteratively modifying the initial QPS based on the multiple second execution average response times.

[0134] It should be understood that the above-mentioned consecutive set number of second execution average response times refers to the multiple second execution average response times obtained by continuously stress testing the first SQL for a set number of times.

[0135] It should be noted that in order to improve the speed of determining the target QPS, the initial QPS can be greatly modified and adjusted first, and after determining that the QPS obtained from the modification meets certain conditions, that is, when it is determined that the QPS corresponding to the first SQL tends to be stable, the QPS is finely adjusted, so as to ensure the accuracy of the target QPS while improving the speed of determining the target QPS. Therefore, the above-mentioned preset execution average response time conditions can include multiple sub-conditions. For example, the above-mentioned preset execution average response time conditions can include two sub-conditions. Among them, the first sub-condition can be: the increase value of each modification of the initial QPS is less than the set increase threshold (such as, 10), and the second sub-condition can still be that the consecutive set number of second execution average response times all belong to the response time fluctuation interval set for the first execution average response time.

[0136] S404: Use the target QPS as the second QPS average value obtained by performing capacity water level detection on the first SQL this time.

[0137] Based on the method for determining the second QPS average value recorded in the above steps S401 - S404, the server can implement the method for determining the second QPS average value as shown below. The specific method process is as follows:

[0138] Step 1: Obtain the normal load QPS of the target database, and stress test the first SQL in the target database based on the normal load QPS to obtain the first execution average response time.

[0139] The above normal load QPS is also the QPS of the SQL normally executed in the target database.

[0140] Step 2: Determine whether the performance metric exceeds the threshold. If so, decrease the QPS corresponding to the first SQL and transfer to Step 1. If not, record the current QPS and the first average execution response time as the baseline values and transfer to Step 3.

[0141] Step 3: Record the current QPS as the QPS increase value or the initial QPS, and based on this QPS, perform multiple stress tests on the first SQL in the target database, and compare the second average execution response time obtained from each stress test with the first average execution response time.

[0142] Step 4: Whether the second average execution response time obtained from consecutive stress tests (e.g., 6 times) all exceed the first average execution response time. If so, halve the QPS increase value, and add the halved QPS increase value to the initial QPS as the new baseline QPS, and transfer to Step 3; if not, transfer to Step 5.

[0143] Step 5: Whether the second average execution response time obtained from consecutive stress tests (e.g., 6 times) all do not exceed the first average execution response time. If so, halve the QPS increase value, and add the halved QPS increase value to the initial QPS as the new baseline QPS, and transfer to Step 3; if not, transfer to Step 6.

[0144] Step 6: The QPS increase value is less than the set increase threshold. If not, halve the QPS increase value, and add the halved QPS increase value to the initial QPS as the new baseline QPS, and transfer to Step 3; if so, transfer to Step 7.

[0145] For example, the above set increase threshold can be 10, or it can be other values, and the embodiments of the present application do not make specific limitations on this. It should be understood that when the QPS increase value is less than the above set increase threshold, it can be determined that the obtained QPS is already very close to the accurate value and tends to be stable. Therefore, the QPS fine-tuning stage can be entered.

[0146] It should be noted that when executing Step 4, Step 5, or Step 6, if the state corresponding to the second average execution response time obtained from consecutive stress tests when the QPS increase value was halved last time is opposite to the state corresponding to the second average execution response time obtained from consecutive stress tests when the QPS increase value is halved this time (for example, this time all exceed, and last time all did not exceed), then the QPS increase value can be reversed, that is, the signs of the two QPS increase values are opposite.

[0147] Step 7: Based on the obtained QPS, continue to perform multiple stress tests on the first SQL in the target database, and compare the second average execution response time obtained from each stress test with the first average execution response time.

[0148] Step 8: Whether the second average execution response time obtained from consecutive stress tests exceeds the first average execution response time. If so, increase or decrease the QPS by the set increase threshold and transfer to Step 7; if not, transfer to Step 9.

[0149] Step 9: Whether the second average execution response time obtained from consecutive stress tests does not exceed the first average execution response time. If so, increase or decrease the QPS by the set increase threshold and transfer to Step 7; if not, transfer to Step 10.

[0150] Step 10: Whether the second average execution response time obtained from consecutive stress tests all fall within the response time fluctuation range set for the first average execution response time. If not, increase or decrease the QPS by the set increase threshold and transfer to Step 7; if so, transfer to Step 11. Exemplarily, the above response time fluctuation range can be an interval of plus or minus 10% based on the first average execution response time, and the embodiments of the present application do not limit this.

[0151] Step 11: Whether the number of adjustments or modifications to the initial QPS exceeds the set number limit. If so, transfer to Step 3; if not, transfer to Step 12.

[0152] Step 12: Use the QPS obtained from the last modification as the target QPS (i.e., the second QPS average value obtained from the capacity water level detection of the first SQL this time).

[0153] Based on the SQL capacity water level detection method described in the above steps S201 - S203, once a capacity water level detection request for the first SQL is received, the log information of the target database can be obtained. Then, according to the SQL execution situations corresponding to multiple SQLs executed in the target database included in the log information, the first QPS average values corresponding to multiple SQLs can be determined. Furthermore, during the process of executing multiple SQLs in the target database according to multiple first QPSs, the capacity water level detection of the first SQL is performed to obtain the capacity water level threshold of the first SQL, thereby realizing the detection of the capacity water level threshold of a single SQL.

[0154] Since the capacity water level detection for the first SQL is time-consuming, detection models corresponding to the capacity water levels can be pre-trained for different SQLs. Subsequently, if it is necessary to estimate the capacity water level threshold of an SQL, it is possible to directly go to the detection model, first match whether there is model data with the same SQL fingerprint as the SQL to be detected (such as the first SQL). If it exists, the capacity water level threshold corresponding to the detection model is directly returned. If it does not exist, a detection model with the closest cost to the SQL to be detected is matched, and the capacity water level threshold corresponding to the detection model is used as the return value. By adopting this method, the capacity water level threshold of the SQL to be detected can be quickly estimated.

[0155] Therefore, in an alternative implementation, refer to Figure 5 As shown, the server can calculate the hash value of the first SQL based on the statement information of the first SQL and generate the first SQL fingerprint based on the hash value. If there is a target SQL fingerprint in the SQL fingerprints of the above multiple SQLs (such as SQL_1 to SQL_5) that is the same as the first SQL fingerprint, the capacity water level threshold of the SQL corresponding to the target SQL fingerprint can be used as the capacity water level threshold of the first SQL. Among them, the first SQL fingerprint can be used to standardize and normalize the first SQL.

[0156] Optionally, refer to Figure 6 As shown, if there is no target SQL fingerprint in the SQL fingerprints of the above multiple SQLs, the server can obtain the SQL costs corresponding to the multiple SQLs respectively, and then based on the SQL cost similarity between the first SQL and the multiple SQLs respectively, screen out the target SQL that meets the preset SQL cost similarity condition with the SQL cost of the first SQL from the multiple SQLs, and then use the capacity water level threshold of the target SQL as the capacity water level threshold of the first SQL. Among them, each SQL cost can represent the resource occupancy required to execute the corresponding SQL, and the preset SQL cost similarity condition can be used to determine the SQL (i.e., the target SQL) with the highest SQL cost similarity to the first SQL.

[0157] It can be seen from this that based on the SQL capacity water level detection method provided in the embodiments of the present application, not only the detection of the capacity water level threshold of a single SQL is realized, but also the stable operation of the target database is ensured. Moreover, the two implementation solutions of rapid estimation and accurate stress testing can more flexibly adapt to various capacity water level threshold detection scenarios.

[0158] In summary, in the SQL capacity water level detection method provided by the embodiments of the present application, once a capacity water level detection request for the first SQL is received, the log information of the target database can be obtained, and then, according to the SQL execution conditions respectively corresponding to multiple SQLs executed in the target database, the first QPS average values respectively corresponding to the multiple SQLs can be determined. Furthermore, during the process of executing multiple SQLs in the target database according to the multiple first QPS values, the capacity water level of the first SQL is detected to obtain the capacity water level threshold of the first SQL, realizing the detection of the capacity water level threshold of a single SQL.

[0159] Further, based on the same technical concept, the embodiments of the present application provide a SQL capacity water level detection device, and this SQL capacity water level detection device is used to implement the above method flow of the embodiments of the present application. Refer to Figure 7 As shown, the SQL capacity water level detector 700 may include: an acquisition module 701, a determination module 702, and a detection module 703, where:

[0160] The acquisition module 701 is configured to, in response to a capacity water level detection request for the first SQL, acquire the log information of the target database; the log information includes: the SQL execution conditions respectively corresponding to multiple SQLs executed in the target database;

[0161] The determination module 702 is configured to determine the first QPS average values respectively corresponding to the multiple SQLs based on the log information;

[0162] The detection module 703 is configured to execute multiple SQLs in the target database according to the obtained multiple first QPS average values, and during the execution of the multiple SQLs, detect the capacity water level of the first SQL to obtain the capacity water level threshold of the first SQL; the capacity water level threshold represents: the maximum QPS when the first SQL is executed in the target database.

[0163] In an alternative embodiment, when executing multiple SQLs in the target database according to the obtained multiple first QPS average values, the detection module 703 is specifically configured to:

[0164] Determine the business low peak period of the target database based on the log information; the business low peak period is a time period during which the duration of the business occupying resources less than the set resource occupation threshold is greater than the set duration threshold;

[0165] During the business low peak period, execute multiple SQLs in the target database according to the multiple first QPS average values.

[0166] In an alternative embodiment, when detecting the capacity water level of the first SQL during the execution of the multiple SQLs to obtain the capacity water level threshold of the first SQL, the detection module 703 is specifically configured to:

[0167] Perform multiple capacity water level detections on the first SQL based on a preset detection duration and a set thread concurrency threshold, and obtain multiple second QPS means;

[0168] Obtain the capacity water level threshold of the first SQL based on the multiple second QPS means.

[0169] In an alternative embodiment, when performing multiple capacity water level detections on the first SQL based on a preset detection duration and a set thread concurrency threshold to obtain multiple second QPS means, the detection module 703 is specifically configured to:

[0170] Determine the number of concurrent threads used when executing multiple SQLs in the target database, and determine the maximum number of concurrent threads for executing the first SQL based on the number of concurrent threads and the thread concurrency threshold;

[0171] During the process of executing the first SQL based on the maximum number of concurrent threads, perform multiple capacity water level detections on the first SQL according to the detection duration, and obtain multiple second QPS means.

[0172] In an alternative embodiment, when performing multiple capacity water level detections on the first SQL to obtain multiple second QPS means, the detection module 703 is specifically configured to:

[0173] During each process of performing a capacity water level detection on the first SQL, perform the following operations respectively:

[0174] When it is determined that the first execution average response time of the first SQL is less than or equal to the set execution average response time threshold, record the initial QPS corresponding to the first SQL;

[0175] Perform multiple stress tests on the first SQL based on the initial QPS, and obtain multiple second execution average response times;

[0176] Iteratively modify the initial QPS based on the multiple second execution average response times until a target QPS that meets the preset execution average response time condition is obtained;

[0177] Use the target QPS as the second QPS mean obtained from this capacity water level detection of the first SQL.

[0178] In an alternative embodiment, the detection module 703 is further configured to:

[0179] Calculate the hash value of the first SQL based on the statement information of the first SQL, and generate a first SQL fingerprint based on the hash value; the first SQL fingerprint is used to perform standardization and normalization processing on the first SQL;

[0180] If there is a target SQL fingerprint in the SQL fingerprints of multiple SQLs that is the same as the first SQL fingerprint, then use the capacity water level threshold of the SQL corresponding to the target SQL fingerprint as the capacity water level threshold of the first SQL.

[0181] In an alternative embodiment, the detection module 703 is further configured to:

[0182] If there is no target SQL fingerprint in the SQL fingerprints of multiple SQLs, obtain the SQL costs corresponding to the multiple SQLs respectively; where each SQL cost represents the resource occupancy required to execute the corresponding SQL;

[0183] Based on the SQL cost similarity between the first SQL and the multiple SQLs respectively, screen out target SQLs from the multiple SQLs whose SQL costs meet the preset SQL cost similarity conditions with the first SQL;

[0184] Use the capacity water level threshold of the target SQL as the capacity water level threshold of the first SQL.

[0185] Based on the descriptions of the above method embodiments and apparatus embodiments, an exemplary embodiment of the present invention further provides an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor. The memory stores a computer program that can be executed by the at least one processor, and when the computer program is executed by the at least one processor, it is used to cause the electronic device to execute the method according to the embodiments of the present invention.

[0186] An embodiment of the present application further provides a non-transitory computer-readable storage medium storing a computer program, where the computer program is used to cause a computer to execute the method according to the embodiments of the present application when executed by a processor of the computer.

[0187] An embodiment of the present application further provides a computer program product, including a computer program, where the computer program is used to cause a computer to execute the method according to the embodiments of the present application when executed by a processor of the computer.

[0188] Refer to Figure 8As shown, the structural block diagram of an electronic device 800 that can be used as a server or a client in this application will now be described. It is an example of a hardware device that can be applied to various aspects of this application. The electronic device is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of this application described and / or claimed herein.

[0189] As Figure 8 shown, the electronic device 800 includes a computing unit 801, which can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 802 or the computer program loaded from the storage unit 808 into the random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the device 800 can also be stored. The computing unit 801, the ROM 802, and the RAM 803 are connected to each other through a bus 804. The input / output (I / O) interface 805 is also connected to the bus 804.

[0190] Multiple components in the electronic device 800 are connected to the I / O interface 805, including: an input unit 806, an output unit 807, a storage unit 808, and a communication unit 809. The input unit 806 can be any type of device that can input information into the electronic device 800. The input unit 806 can receive input digital or character information, and generate key signal inputs related to the user settings and / or function controls of the electronic device. The output unit 807 can be any type of device that can present information, and can include but is not limited to a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. The storage unit 808 can include but is not limited to a magnetic disk, an optical disk. The communication unit 809 allows the electronic device 800 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks, and can include but is not limited to a modem, a network card, an infrared communication device, a wireless communication transceiver, and / or a chipset, such as a Bluetooth device, a WiFi device, a worldwide interoperability for microwave access (WiMax) device, a cellular communication device, and / or the like.

[0191] The computing unit 801 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 801 executes the various methods and processes described above. For example, in some embodiments, the above-described SQL capacity water level detection method can be implemented as a computer software program that is tangibly included in a machine-readable medium, such as the storage unit 808. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 800 via the ROM 802 and / or the communication unit 809. In some embodiments, the computing unit 801 can be configured to execute the above-described SQL capacity water level detection method by any other suitable means (e.g., by means of firmware).

[0192] The program code for implementing the methods of the present application can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the program codes are executed by the processor or controller, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The program code can be executed entirely on the machine, partially on the machine, executed partially on the machine and partially on a remote machine as an independent software package, or executed entirely on a remote machine or server.

[0193] In the context of this application, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM) or flash memory, an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0194] As used in this application, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and / or device (e.g., a disk, an optical disk, a memory, a programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.

[0195] To provide for interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a cathode ray tube (CRT) or a liquid crystal display (LCD) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computer. Other kinds of devices can also be used to provide for interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic, speech, or tactile input).

[0196] The systems and techniques described herein can be implemented in a computing system including backend components (e.g., as a data server), or a computing system including middleware components (e.g., an application server), or a computing system including frontend components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described herein), or a computing system including any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected to each other by digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0197] A computer system can include a client and a server. The client and the server are generally remote from each other and typically interact through a communication network. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other.

[0198] Also, it should be understood that the foregoing disclosure is only a preferred embodiment of the present application, and of course cannot be used to limit the scope of the rights of the present invention. Therefore, equivalent changes made in accordance with the claims of the present invention still fall within the scope covered by the present application.

Claims

1. A method for detecting the capacity water level of Structured Query Language (SQL), characterized in that, Including: In response to a capacity water level detection request for the first SQL, obtain the log information of the target database; The log information includes: the SQL execution conditions corresponding to multiple SQLs executed in the target database; Based on the log information, determine the first average Query Per Second (QPS) values corresponding to the multiple SQLs respectively; Execute the multiple SQLs in the target database according to the obtained multiple first QPS values, and perform capacity water level detection on the first SQL during the execution of the multiple SQLs to obtain the capacity water level threshold of the first SQL; the capacity water level threshold represents: the maximum QPS when the first SQL is executed in the target database.

2. The method according to claim 1, characterized in that The step of executing the multiple SQLs in the target database according to the obtained multiple first QPS values includes: Based on the log information, determine the off-peak period of the business in the target database; the off-peak period of the business is a time period during which the resource occupancy by the business is less than a set resource occupancy threshold and the continuous duration is greater than a set continuous duration threshold; During the off-peak period of the business, execute the multiple SQLs in the target database according to the multiple first QPS values.

3. The method according to claim 1, characterized in that, The step of performing capacity water level detection on the first SQL during the execution of the multiple SQLs to obtain the capacity water level threshold of the first SQL includes: Based on a preset detection duration and a set thread concurrency threshold, perform multiple capacity water level detections on the first SQL to obtain multiple second QPS values; Based on the multiple second QPS values, obtain the capacity water level threshold of the first SQL.

4. The method according to claim 3, wherein The step of performing multiple capacity water level detections on the first SQL based on a preset detection duration and a set thread concurrency threshold to obtain multiple second QPS values includes: Determine the number of concurrent threads used when executing the multiple SQLs in the target database, and based on the number of concurrent threads and the thread concurrency threshold, determine the maximum number of concurrent threads for executing the first SQL; During the execution of the first SQL based on the maximum number of concurrent threads, perform multiple capacity water level detections on the first SQL according to the detection duration to obtain the multiple second QPS values.

5. The method according to claim 3 or 4, characterized in that, The step of performing multiple capacity water level detections on the first SQL to obtain multiple second QPS values includes: During each capacity water level detection of the first SQL, perform the following operations respectively: When it is determined that the first average execution response time of the first SQL is less than or equal to a set execution average response time threshold, record the initial QPS corresponding to the first SQL; Based on the initial QPS, perform multiple stress tests on the first SQL to obtain multiple second average execution response times; Iteratively modify the initial QPS based on the multiple second average execution response times until a target QPS that meets the preset execution average response time condition is obtained; Take the target QPS as the second QPS value obtained from the capacity water level detection of the first SQL this time.

6. The method according to claim 5, wherein The preset execution average response time condition is that the second execution average response times of a continuous set number all belong to the response time fluctuation range set for the first execution average response time.

7. The method according to any one of claims 1 to 4, characterized in that The method further includes: Calculating a hash value of the first SQL based on the statement information of the first SQL, and generating a first SQL fingerprint based on the hash value; the first SQL fingerprint is used for standardizing and normalizing the first SQL; If there is a target SQL fingerprint identical to the first SQL fingerprint among the SQL fingerprints of the multiple SQLs, then using the capacity water level threshold of the SQL corresponding to the target SQL fingerprint as the capacity water level threshold of the first SQL.

8. The method according to claim 7, wherein The method further includes: If there is no such target SQL fingerprint among the SQL fingerprints of the multiple SQLs, then obtaining the SQL costs corresponding to the multiple SQLs respectively; where each SQL cost represents the resource occupancy required to execute the corresponding SQL; Based on the SQL cost similarity between the first SQL and the multiple SQLs respectively, screening out target SQLs from the multiple SQLs whose SQL costs meet a preset SQL cost similarity condition with the first SQL; Using the capacity water level threshold of the target SQL as the capacity water level threshold of the first SQL.

9. A capacity water level detection device for SQL, characterized in that, Including: An obtaining module, configured to obtain log information of a target database in response to a capacity water level detection request for a first SQL; The log information includes: the SQL execution conditions respectively corresponding to multiple SQLs executed in the target database; A determining module, configured to determine the first query per second (QPS) mean values respectively corresponding to the multiple SQLs based on the log information; A detecting module, configured to execute the multiple SQLs in the target database according to the obtained multiple first QPS mean values, and perform capacity water level detection on the first SQL during the execution of the multiple SQLs, to obtain a capacity water level threshold of the first SQL; the capacity water level threshold represents: the maximum QPS when executing the first SQL in the target database.

10. An electronic device, including: A processor; And A memory storing a program, wherein the program includes instructions that, when executed by the processor, cause the processor to execute the method according to any one of claims 1-8.