Database response time testing method and device, equipment and medium

By executing structured query statements in the database and counting hardware resource consumption, the database response time is directly determined, which solves the problems of low testing efficiency and high cost in the existing technology, and achieves fast and efficient database response time testing.

CN119473827AActive Publication Date: 2025-02-18TIANJIN NANKAI UNIV GENERAL DATA TECH
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202510051908.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-14
Publication Date
2025-02-18
Estimated Expiration
2045-01-14

AI Technical Summary

Technical Problem

When testing whether a database can meet the response time requirements under large data volume and large concurrency volume, the prior art requires loading a large amount of test data related to business logic into the database, resulting in low testing efficiency and consuming a lot of time and labor costs.

Method used

In response to receiving the test request, the structured query statement used to test the database is determined based on the test request, and the execution plan and hardware resource consumption parameters of the database when executing each structured query statement are obtained, and based on this information, it is determined that the database executes each of the database to execute each structured query statement. The hardware resource consumption information and response time of the structured query statement.

Benefits of technology

There is no need to load a large amount of test data in the database, and directly count hardware resource consumption through a single execution of structured query statements, which improves testing efficiency, reduces time and labor costs, and can test the database at any time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119473827A_ABST
    Figure CN119473827A_ABST
Patent Text Reader

Abstract

The invention provides a database response time testing method and device, equipment and a storage medium, and can be applied to the technical field of databases. The method comprises the steps that in response to a received test request, based on the test request, at least one structured query statement used for testing a database is determined, the test request comprises test conditions, and the test conditions comprise hardware resource configuration parameters, data volume parameters and concurrency parameters; obtaining an execution plan and a hardware resource consumption parameter when the database executes each structured query statement; determining hardware resource consumption information of the database for executing each structured query statement based on table information of the data table corresponding to each structured query statement, the execution plan and the hardware resource consumption parameters; and based on the hardware resource consumption information, the hardware resource configuration parameter, the data volume parameter and the concurrency parameter, determining the response time of the database for executing each structured query statement under the test condition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of database technology, and more specifically to a method, device, equipment and medium for testing database response time. Background Art

[0002] With the rapid development of cloud computing and distributed technology, the amount of data in various business systems has also increased significantly. And with the substantial increase in data volume, database bottlenecks have gradually become prominent. Therefore, it is necessary to test whether the database can meet the response time requirements under large data volumes and large concurrency, so as to make timely response measures.

[0003] Usually, when testing whether a database can meet the response time requirements, it is necessary to load test data into the database and execute structured query statements corresponding to the business to simulate the business and perform database operations. However, when loading test data into the database, the process of loading a large amount of data related to business logic consumes a lot of time and manpower costs, resulting in low test efficiency. Summary of the invention

[0004] In view of the above problems, the present invention provides a method, device, equipment, medium and program product for testing database response time.

[0005] According to a first aspect of the present invention, a method for testing database response time is provided, comprising: in response to receiving a test request, determining at least one structured query statement for testing the database based on the test request, wherein the test request includes a test condition, the test condition includes a hardware resource configuration parameter, a data volume parameter and a concurrency parameter, and the concurrency parameter represents the concurrency of at least one structured query statement; obtaining an execution plan and hardware resource consumption parameters when the database executes each structured query statement; determining hardware resource consumption information when the database executes each structured query statement based on table information, an execution plan and hardware resource consumption parameters of a data table corresponding to each structured query statement, wherein the table information includes: table structure information, table data volume information and table index information; and determining the response time of the database executing each structured query statement under the test condition based on the hardware resource consumption information, the hardware resource configuration parameters, the data volume parameters and the concurrency parameters.

[0006] According to an embodiment of the present invention, based on the table information of the data table corresponding to the structured query statement, the execution plan and the hardware resource consumption parameters, the hardware resource consumption information of the database executing each structured query statement is determined, including: determining at least one database operator used by the database when executing the structured query statement according to the execution plan; determining the respective sub-hardware resource consumption parameters of each database operator according to the at least one database operator, the hardware resource consumption parameters and the table information of the data table corresponding to the structured query statement; and determining the hardware resource consumption information according to each database operator and the respective sub-hardware resource consumption parameters of each database operator.

[0007] According to an embodiment of the present invention, based on a test request, at least one structured query statement for testing a database is determined, including: in response to determining that the test request includes a database script for testing the database, obtaining at least one initial structured query statement in the database script; and determining at least one structured query statement based on the at least one initial structured query statement and data stored in the database.

[0008] According to an embodiment of the present invention, at least one structured query statement is determined based on at least one initial structured query statement and data stored in a database, including: in response to determining that there are query parameters with missing parameter values ​​in the initial structured query statement, querying the data stored in the database according to the field name corresponding to the query parameter to obtain target data, wherein the query parameter is used to locate the row where the to-be-queried data corresponding to the initial structured query statement is located; and based on the target data, determining the parameter value of the query parameter in the initial structured query statement to obtain the structured query statement.

[0009] According to an embodiment of the present invention, the method further includes: obtaining a structured query statement for testing the database from the test request.

[0010] According to an embodiment of the present invention, based on hardware resource consumption information, hardware resource configuration parameters, data volume parameters and concurrency parameters, the response time of each structured query statement executed by the database under test conditions is determined, including: for each structured query statement, the hardware resource configuration parameters, data volume parameters and concurrency parameters as well as the hardware resource consumption information of the structured query statement are input into a time prediction model to obtain the response time corresponding to the structured query statement.

[0011] According to an embodiment of the present invention, the method also includes: based on the response time corresponding to each structured query statement, determining a target structured query statement whose response time is greater than a preset threshold from at least one structured query statement; and based on the target structured query statement and the data table corresponding to the target structured query statement, determining target impact information from multiple impact information that affect the response time, wherein the multiple impact information includes: table index information of the data table, table structure information of the data table, and the target structured query statement.

[0012] The second aspect of the present invention provides a test device for database response time, comprising: a statement determination module, in response to receiving a test request, determining at least one structured query statement for testing the database based on the test request, wherein the test request includes a test condition, the test condition includes a hardware resource configuration parameter, a data volume parameter and a concurrency parameter, and the concurrency parameter represents the concurrency of at least one structured query statement; a parameter acquisition module, used to obtain an execution plan and hardware resource consumption parameters when the database executes each structured query statement; a consumption determination module, used to determine the hardware resource consumption information of the database executing each structured query statement based on the table information, execution plan and hardware resource consumption parameters of the data table corresponding to each structured query statement, wherein the table information includes: table structure information, table data volume information and table index information; and a time determination module, used to determine the response time of the database executing each structured query statement under the test condition based on the hardware resource consumption information, hardware resource configuration parameters, data volume parameters and concurrency parameters.

[0013] A third aspect of the present invention provides an electronic device, comprising: one or more processors; a memory for storing one or more computer programs, wherein the one or more processors execute the one or more computer programs to implement the steps of the above method.

[0014] The fourth aspect of the present invention further provides a computer-readable storage medium on which a computer program or instruction is stored, and the steps of the above method are implemented when the above computer program or instruction is executed by a processor.

[0015] The fifth aspect of the present invention also provides a computer program product, including a computer program or instructions, which implement the steps of the above method when executed by a processor.

[0016] According to an embodiment of the present invention, by determining a structured query statement for testing a database based on a test request, and setting test conditions such as hardware resource configuration parameters, data volume parameters, and concurrency parameters, the response time of a database executing a specific business under specific test conditions can be tested. In addition, by obtaining the execution plan and hardware resource consumption parameters of the structured query statement actually executed by the database as reference information for determining the hardware resource consumption parameters, the hardware resource consumption information is determined using the database hardware resource consumption parameters, table information, and execution plan, so that the hardware resource consumption information is authentic while improving the richness of the hardware resource consumption information, thereby improving the accuracy of the determined response time. In addition, by using the hardware resource consumption information of a single execution of a structured query statement by the database to determine the response time under test conditions, there is no need to load a large amount of test data in the database, thereby improving the test efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The above contents and other objects, features and advantages of the present invention will become more apparent through the following description of the embodiments of the present invention with reference to the accompanying drawings, in which:

[0018] Figure 1 An application scenario diagram of a method, apparatus, device, medium, and program product for testing database response time according to an embodiment of the present invention is shown.

[0019] Figure 2 A flow chart of a method for testing database response time according to an embodiment of the present invention is shown.

[0020] Figure 3 A data flow diagram for determining a structured query statement according to a specific embodiment of the present invention is shown.

[0021] Figure 4 A flowchart of a test database according to a specific embodiment of the present invention is shown.

[0022] Figure 5 A structural block diagram of a database response time testing device according to an embodiment of the present invention is shown.

[0023] Figure 6 A block diagram of an electronic device suitable for implementing a method for testing database response time according to an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0024] Below, embodiments of the present invention will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present invention. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of embodiments of the present invention. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of concepts of the present invention.

[0025] The terms used herein are only for describing specific embodiments and are not intended to limit the present invention. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0026] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.

[0027] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).

[0028] In the technical solution of the present invention, the user information (including but not limited to user personal information, user image information, user device information, such as location information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved are all information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with relevant laws, regulations and standards, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0029] In the scenario of using personal information for automated decision-making, the methods, devices, and systems provided by the embodiments of the present invention provide users with corresponding operation portals for users to choose to agree or reject the automated decision-making results; if the user chooses to reject, the expert decision-making process will be entered. The expression "automated decision-making" here refers to the activity of automatically analyzing and evaluating an individual's behavioral habits, interests and hobbies, or economic, health, credit status, etc. through computer programs, and making decisions. The expression "expert decision-making" here refers to the activity of making decisions by people who specialize in a certain field, have specialized experience, knowledge and skills, and have reached a certain level of professionalism.

[0030] When testing whether the database can meet the response requirements, it is usually necessary to load data into the database and then execute structured query statements corresponding to the business to simulate the business and perform database operations. Since the loaded test data must also be related to the business logic, it is also necessary to analyze the business-related data when loading the data, which is time-consuming and labor-intensive. In addition, the large amount of loaded data will not only increase the database maintenance cost, but also have certain hardware resource requirements for the server environment, such as the central processing unit (CPU), memory capacity, and disk capacity. In addition, since it is impossible to store a large amount of loaded test data for a long time, it is also impossible to test the response time of the database at any time.

[0031] An embodiment of the present invention provides a method for testing database response time. In response to receiving a test request, at least one structured query statement for testing the database is determined based on the test request, wherein the test request includes a test condition, and the test condition includes a hardware resource configuration parameter, a data volume parameter, and a concurrency parameter, and the concurrency parameter represents the concurrency of at least one structured query statement; an execution plan and hardware resource consumption parameters when the database executes each structured query statement are obtained; based on table information, an execution plan, and hardware resource consumption parameters of a data table corresponding to each structured query statement, hardware resource consumption information when the database executes each structured query statement is determined, wherein the table information includes: table structure information, table data volume information, and table index information; and based on the hardware resource consumption information, the hardware resource configuration parameters, the data volume parameters, and the concurrency parameters in the test conditions, the response time of the database executing each structured query statement under the test conditions is determined. In order to solve the above technical problems, the embodiment of the present invention executes a structured query statement only once in the database, and determines the database response time under test conditions by counting the hardware resource consumption of the database when executing the structured query statement. Therefore, it is possible to avoid loading a large amount of data related to business logic in the database. Not only does it not need to consume time and manpower to load data, but it also does not require the hardware resource conditions of the server environment. The database can be tested at any time, thereby improving test efficiency.

[0032] Figure 1 An application scenario diagram of a method, apparatus, device, medium, and program product for testing database response time according to an embodiment of the present invention is shown.

[0033] like Figure 1 As shown, the application scenario 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 is used to provide a medium for a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.

[0034] The user can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only for example).

[0035] The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0036] The server 105 may be a server that provides various services, such as a background management server (only as an example) that provides support for websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.

[0037] Specifically, the server 105 may be a server providing database services or a server providing database testing services. The user uses the first terminal device 101, the second terminal device 102 or the third terminal device 103 to send a test request to the server 105 through the network 104. In response to receiving the test request, the server 105 determines at least one structured query statement for testing the database based on the test request, wherein the test request includes a test condition, the test condition includes a hardware resource configuration parameter, a data volume parameter and a concurrency parameter, and the concurrency parameter represents the concurrency of at least one structured query statement; obtains the execution plan and hardware resource consumption parameters when the database executes each structured query statement; determines the hardware resource consumption information of the database executing each structured query statement based on the table information, execution plan and hardware resource consumption parameters of the data table corresponding to each structured query statement, wherein the table information includes: table structure information, table data volume information and table index information; and determines the response time of the database executing each structured query statement under the test condition based on the hardware resource consumption information, hardware resource configuration parameters, data volume parameters and concurrency parameters.

[0038] It should be noted that the test method for database response time provided in the embodiment of the present invention can generally be executed by the server 105. Accordingly, the test device for database response time provided in the embodiment of the present invention can generally be set in the server 105. The test method for database response time provided in the embodiment of the present invention can also be executed by a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105. Accordingly, the test device for database response time provided in the embodiment of the present invention can also be set in a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105.

[0039] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0040] The following will be based on Figure 1 The scene described by Figure 2~Figure 4 The method for testing the database response time according to the embodiment of the present invention is described in detail.

[0041] Figure 2 A flow chart of a method for testing database response time according to an embodiment of the present invention is shown.

[0042] like Figure 2As shown, the method for testing the database response time of this embodiment includes operations S210 to S240.

[0043] In operation S210 , in response to receiving a test request, at least one structured query statement for testing a database is determined based on the test request.

[0044] According to an embodiment of the present invention, a user can directly input at least one structured query statement for testing a database in a test interface of a terminal, upload a database script for testing a database to the test interface, or connect the database script to a database through an interface.

[0045] According to an embodiment of the present invention, when the user input includes a database script, the database script may be parsed to obtain at least one structured query statement for testing from the database script.

[0046] According to an embodiment of the present invention, the test request includes a test condition, and the user can also enter the test condition in the test interface of the terminal. The test condition includes a hardware resource configuration parameter, a data volume parameter, and a concurrency parameter. The concurrency parameter represents the concurrency of at least one structured query statement, and the data volume parameter can represent that the data volume under the test condition is a multiple of the current data volume stored in the database.

[0047] In operation S220, the execution plan and hardware resource consumption parameters when the database executes each structured query statement are obtained.

[0048] According to an embodiment of the present invention, the execution plan may include multiple operations when the database executes the structured query statement and the order of the multiple operations. The hardware resource consumption parameter may characterize the hardware resource consumption of the database when executing the structured query statement. Specifically, the hardware resource consumption may include CPU consumption, memory consumption, and disk consumption.

[0049] According to an embodiment of the present invention, when obtaining an execution plan, after executing a structured query statement in the database, the corresponding execution plan can be queried in the database according to the execution plan query instruction corresponding to the database. When obtaining hardware resource consumption parameters, the corresponding hardware resource consumption information can also be queried in the database according to the hardware resource consumption query instruction corresponding to the database, or the hardware resource consumption information can be obtained by directly monitoring the hardware resource consumption of the server during the execution of the structured query statement.

[0050] In operation S230 , based on table information of a data table corresponding to each structured query statement, an execution plan, and hardware resource consumption parameters, hardware resource consumption information of executing each structured query statement by the database is determined.

[0051] According to an embodiment of the present invention, table information includes: table structure information, table data volume information, and table index information. Specifically, the table structure information may include field information, table creation statements, and metadata in the data table, the table data volume information may include the amount of data currently stored in the data table, such as the number of table rows, and the table index information may include information such as the column where the data table index is located.

[0052] In operation S240, based on the hardware resource consumption information, the hardware resource configuration parameters, the data volume parameters, and the concurrency volume parameters, the response time of the database executing each structured query statement under the test condition is determined.

[0053] According to an embodiment of the present invention, under conditions of large data volume and large concurrency, the hardware resources of the server cannot respond to a large number of concurrent structured query statements at one time, and queuing will occur. Therefore, it is necessary to determine whether there is a queuing situation when executing a large number of concurrent structured query statements, as well as information such as the queuing time, through the hardware resource consumption information and hardware resource configuration parameters of a single execution of the structured query statement, and then determine the response time.

[0054] According to an embodiment of the present invention, the response time of executing each structured query statement by the database may also be obtained, and then the response time of executing each structured query statement under the test condition may be inferred.

[0055] According to an embodiment of the present invention, the hardware resource consumption information, the hardware resource configuration parameters in the test conditions, the data volume parameters and the concurrency parameters can be input into a machine learning model, etc. to determine the response time. The hardware resource consumption information, the hardware resource configuration parameters in the test conditions, the data volume parameters and the concurrency parameters can also be input into a statistical model to determine the response time.

[0056] According to an embodiment of the present invention, by determining a structured query statement for testing a database based on a test request, and setting test conditions such as hardware resource configuration parameters, data volume parameters, and concurrency parameters, the response time of a database executing a specific business under specific test conditions can be tested. In addition, by obtaining the execution plan and hardware resource consumption parameters of the structured query statement actually executed by the database as reference information for determining the hardware resource consumption parameters, the hardware resource consumption information is determined using the database hardware resource consumption parameters, table information, and execution plan, so that the hardware resource consumption information is authentic while improving the richness of the hardware resource consumption information, thereby improving the accuracy of the determined response time. In addition, by using the hardware resource consumption information of a single execution of a structured query statement by the database to determine the response time under test conditions, there is no need to load a large amount of test data in the database, thereby improving the test efficiency.

[0057] According to an embodiment of the present invention, based on the table information of the data table corresponding to the structured query statement, the execution plan and the hardware resource consumption parameters, the hardware resource consumption information of the database executing each structured query statement is determined, including: determining at least one database operator used by the database when executing the structured query statement according to the execution plan; determining the respective sub-hardware resource consumption parameters of each database operator according to the at least one database operator, the hardware resource consumption parameters and the table information of the data table corresponding to the structured query statement; and determining the hardware resource consumption information according to each database operator and the respective sub-hardware resource consumption parameters of each database operator.

[0058] According to an embodiment of the present invention, a database operator can represent the specific operations when a database executes a structured query statement. Specifically, an execution plan may include at least one database operator used when the database executes a structured query statement and the execution order between at least one database operator, so the database operator can be obtained from the execution plan.

[0059] According to an embodiment of the present invention, since the hardware resource consumption parameters for executing the structured query statement have been obtained, the hardware resource parameters can be split into sub-resource consumption parameters of at least one database operator.

[0060] According to an embodiment of the present invention, when a database operator performs an operation, the hardware resources consumed are related to the table structure, table index, and table data volume, etc. Therefore, the hardware resource parameters can be split into sub-resource consumption parameters of at least one database operator according to the table information of the data table.

[0061] According to an embodiment of the present invention, when determining sub-resource consumption parameters, at least one database operator, hardware resource consumption parameters and table information of a data table may be input into a resource consumption determination model to determine the sub-hardware resource consumption of each database operator.

[0062] According to an embodiment of the present invention, the hardware resource consumption information may include at least one database operator and the respective sub-hardware resource consumption parameters of each database operator, and then the response time under large concurrency and large data volume conditions may be determined according to the respective sub-hardware resource consumption parameters of each database operator.

[0063] According to an embodiment of the present invention, since the database executes structured query statements in units of database operators, the sub-hardware resource consumption parameters consumed by the database operators are counted, and the hardware resource consumption information is determined based on the more fine-grained sub-hardware resource consumption parameters, and the response time can be determined more accurately based on the hardware resource consumption information.

[0064] According to an embodiment of the present invention, based on a test request, at least one structured query statement for testing a database is determined, including: in response to determining that the test request includes a database script for testing the database, obtaining at least one initial structured query statement in the database script; and determining at least one structured query statement based on the at least one initial structured query statement and data stored in the database.

[0065] According to an embodiment of the present invention, a user can directly upload a database script for testing a database in the test interface. Specifically, the database script can be a database script of an actual business. By using the database script of an actual business to test the database, the database response time when the business is actually executed can be predicted, which is closer to the actual business situation.

[0066] According to an embodiment of the present invention, there may be missing information in at least one initial structured query statement of a database script, and the missing information is usually completed in the process of actually executing the business. Therefore, without actually executing the business, the initial structured query statement cannot be executed in the database due to the missing information.

[0067] According to an embodiment of the present invention, when there is missing information in the initial structured query statement, the initial structured query statement can be completed using data stored in the database to obtain a structured query statement; when there is no missing information in the initial structured query statement, the initial structured query statement can be directly determined to be a structured query statement.

[0068] According to the embodiment of the present invention, by using the data stored in the database to generate a structured query statement, it is avoided to manually load a large amount of test data into the database, thereby improving the test efficiency.

[0069] According to an embodiment of the present invention, at least one structured query statement is determined based on at least one initial structured query statement and data stored in a database, including: in response to determining that there is a query parameter with a missing parameter value in the initial structured query statement, querying the data stored in the database according to the field name corresponding to the query parameter to obtain target data; and determining the parameter value of the query parameter in the initial structured query statement based on the target data to obtain the structured query statement.

[0070] According to an embodiment of the present invention, the initial structured query statement may include a query condition, and the query condition may include a query parameter, and the query parameter is used to locate the row where the to-be-queried data corresponding to the initial structured query statement is located. For example, when the initialization query statement is "SELECT * FROM employees WHERE age > :age", the query parameter is ":age" and the parameter value is missing, and the field name corresponding to the query parameter is "age".

[0071] According to an embodiment of the present invention, since the query parameters of the initial structured query statement are missing parameter values ​​when the business is not actually executed, that is, the query conditions in the initial structured query statement are incomplete, the initial structured query statement cannot be executed normally in the database, and the initial structured query statement needs to be completed to obtain an executable structured query statement.

[0072] According to an embodiment of the present invention, when determining the target data that can be used as a parameter value, the data stored in the database can be queried according to the field name corresponding to the query parameter. Specifically, the field name can be used to query the data stored in the database, obtain the data set corresponding to the field name, and then determine the target data from the data set. For example, all field values ​​corresponding to the field name "age" in the employees table can be queried, and the obtained data set includes {22, 25, 26, 28}, and "25" in the data set is determined as the target data.

[0073] According to an embodiment of the present invention, after determining the target data, the target data can be used as the parameter value of the query parameter to fill in the initial structured query statement to obtain a structured query statement. For example, "25" can be used as the parameter value of the query parameter "age" to obtain a structured query statement "SELECT * FROM employees WHERE age >25".

[0074] According to an embodiment of the present invention, by utilizing the data stored in the database to complete the missing parameter values ​​in the initial structured query statement, a structured query statement can be automatically generated without manually loading a large amount of test data in the database or manually writing the structured query statement based on the loaded data, thereby improving testing efficiency.

[0075] Figure 3 A data flow diagram for determining a structured query statement according to a specific embodiment of the present invention is shown.

[0076] like Figure 3As shown, an initial structured query statement 302 is obtained from a database script 301, a field name 303 corresponding to a query parameter with a missing parameter value is obtained from the initial structured query statement 302, and the field name 303 is used to query the data stored in the database to obtain target data 304. The target data 304 is used to complete the missing parameter value in the initial structured query statement 302 to obtain a target structured query statement 305.

[0077] According to an embodiment of the present invention, determining at least one structured query statement for testing a database based on a test request further includes: acquiring the structured query statement for testing the database from the test request.

[0078] According to an embodiment of the present invention, when the user needs to test the response of the database to complete a simple query task, the user can also directly input a structured query statement for testing the database on the test interface.

[0079] According to an embodiment of the present invention, when a user inputs a structured query statement, the data stored in the database may also be displayed on the test interface, so that the user can directly construct a structured query statement based on the stored data, thereby improving the efficiency of the user in constructing the structured query statement.

[0080] According to an embodiment of the present invention, when it is determined that the structured query statement input by the user is complete, the structured query statement input by the user can be directly used as the structured query statement for testing the database. When it is determined that the structured query statement input by the user is an incomplete statement, the data stored in the database can be used to complete it, and the completed structured query statement can be used as the structured query statement for testing the database.

[0081] According to the embodiment of the present invention, by directly using the structured query statement in the test request to perform the test, the execution status of the database when completing a simple query task can be tested, making the test method diverse and rich.

[0082] According to an embodiment of the present invention, based on hardware resource consumption information, hardware resource configuration parameters, data volume parameters and concurrency parameters, the response time of each structured query statement executed by the database under test conditions is determined, including: for each structured query statement, the hardware resource configuration parameters, data volume parameters and concurrency parameters as well as the hardware resource consumption information of the structured query statement are input into a time prediction model to obtain the response time corresponding to the structured query statement.

[0083] According to an embodiment of the present invention, relevant parameters of the test, such as hardware resource configuration parameters, data volume parameters, and concurrency volume parameters, may be acquired from the test conditions set by the user.

[0084] According to an embodiment of the present invention, the time prediction model can be obtained by pre-training a machine learning model, or by fitting a statistical model with data. Specifically, the hardware resource configuration parameters, data volume parameters, concurrency parameters, and hardware resource consumption information of other databases can be used as training samples, and the corresponding real response time can be used as a label to train the machine learning model.

[0085] According to an embodiment of the present invention, when determining the response time corresponding to each structured query statement, the hardware resource configuration parameters, data volume parameters, concurrency parameters and hardware resource consumption information of the structured query statement can be input into the time prediction model to obtain the response time output by the time prediction model.

[0086] According to the embodiment of the present invention, the response time is predicted using a time prediction model, thereby improving the automation level of the test and further improving the test efficiency.

[0087] According to an embodiment of the present invention, the method for testing database response time also includes: determining a target structured query statement whose response time is greater than a preset threshold from at least one structured query statement based on the response time corresponding to each structured query statement; and determining target impact information from multiple impact information that affect the response time based on the target structured query statement and the data table corresponding to the target structured query statement.

[0088] According to an embodiment of the present invention, a threshold of response time can be preset to determine whether the database has a high time consumption when executing a structured query statement, so as to improve the response speed of the database in a targeted manner. Specifically, when the response time of the structured query statement is greater than the preset threshold, the structured query statement can be determined to be a target structured query statement with high time consumption.

[0089] According to an embodiment of the present invention, the response time of the database may be affected by the data table and the structured query statement. For example, the response time is long because the data table has no index or the index is set irrationally, the response time is long due to certain field types in the data table, and the response time is long because the structured query statement requires the database to perform a full table scan or a subquery.

[0090] According to an embodiment of the present invention, the plurality of impact information includes: table index information of a data table, table structure information of a data table, and a target structured query statement. Specifically, the table index information of a data table may include whether the data table has an index and the column where the index is located, and the table structure information of a data table may include fields in the table and the field type of each field.

[0091] According to an embodiment of the present invention, target impact information can be determined from multiple impact information by rule matching. For example, multiple field types that cause long response time can be preset and matched with field types in table structure information, and the target structured query statement can be scanned to see whether it includes characters representing full table query.

[0092] According to an embodiment of the present invention, after the target influencing factors are determined, the target influencing factors may also be displayed on the user's terminal to facilitate the user to optimize the data table or the target structured query statement according to the target influencing factors.

[0093] According to an embodiment of the present invention, a target influencing factor affecting the response time is determined from multiple influencing factors through automated means, thereby improving the efficiency of determining the target influencing factor and facilitating the user to maintain the database.

[0094] According to an embodiment of the present invention, in addition to the response time, a curve showing the response time changing with the data volume parameter and the hardware resource configuration parameter can also be drawn and displayed on the user terminal. In addition, when the user uploads a database script, the execution frequency or the n structured query statements with the highest execution time can also be analyzed to intuitively display the test results to the user.

[0095] Figure 4 A flowchart of a test database according to a specific embodiment of the present invention is shown.

[0096] like Figure 4 As shown, the test database includes operations S410 to S460.

[0097] In operation S410, after the user configures the test conditions and executes the service for testing the database, the execution plan, table information and hardware resource consumption parameters when the database executes the structured query statement are obtained.

[0098] According to an embodiment of the present invention, a database agent may be used to connect a script of a service to a database and then execute the service. The test conditions may include hardware resource configuration parameters, data volume parameters, and concurrency parameters.

[0099] According to an embodiment of the present invention, the table information may include table structure information, table index information, table data volume information, etc. The hardware resource consumption information may represent the hardware resource consumption of the database when executing a structured query statement.

[0100] According to an embodiment of the present invention, a database may be connected via an interface (connect api) to obtain an execution plan, table information, and hardware resource consumption parameters.

[0101] In operation S420, based on the execution plan, the table information, and the hardware resource consumption parameters, the sub-hardware resource consumption parameters of each database operator during the execution of the structured query statement are determined.

[0102] In operation S430 , hardware resource consumption information is generated based on each database operator and the respective sub-hardware resource consumption parameters of each database operator.

[0103] In operation S440, based on the test condition and the hardware resource consumption information, a response time of the database under the test condition is determined.

[0104] In operation S450, statistics are collected on 20 structured query statements with the longest response time and the structured query statement with the highest execution frequency.

[0105] In operation S460, a target influencing factor influencing the response time is determined.

[0106] According to an embodiment of the present invention, the influencing factors may include table structure information of a data table corresponding to the structured query statement, table index information, and the structured query statement itself.

[0107] Based on the above database response time testing method, the present invention also provides a database response time testing device. Figure 5 The device is described in detail.

[0108] Figure 5 A structural block diagram of a database response time testing device according to an embodiment of the present invention is shown.

[0109] like Figure 5 As shown, the database response time testing device 500 of this embodiment includes a statement determination module 510 , a parameter acquisition module 520 , a consumption determination module 530 and a time determination module 540 .

[0110] The statement determination module 510 is used to determine at least one structured query statement for testing the database in response to receiving a test request based on the test request, wherein the test request includes a test condition, the test condition includes a hardware resource configuration parameter, a data volume parameter, and a concurrency parameter, and the concurrency parameter represents the concurrency of at least one structured query statement. In one embodiment, the statement determination module 510 can be used to perform the operation S210 described above, which will not be repeated here.

[0111] The parameter acquisition module 520 is used to acquire the execution plan and hardware resource consumption parameters when the database executes each structured query statement. In one embodiment, the parameter acquisition module 520 can be used to perform the operation S220 described above, which will not be described in detail here.

[0112] The consumption determination module 530 is used to determine the hardware resource consumption information of the database executing each structured query statement based on the table information, execution plan and hardware resource consumption parameters of the data table corresponding to each structured query statement, wherein the table information includes: table structure information, table data volume information and table index information. In one embodiment, the consumption determination module 530 can be used to perform the operation S230 described above, which will not be repeated here.

[0113] The time determination module 540 is used to determine the response time of the database executing each structured query statement under the test condition based on the hardware resource consumption information, the hardware resource configuration parameters, the data volume parameters and the concurrency volume parameters. In one embodiment, the time determination module 540 can be used to perform the operation S240 described above, which will not be repeated here.

[0114] According to an embodiment of the present invention, the consumption determination module 530 includes an operator determination submodule, a parameter determination submodule and an information determination submodule.

[0115] The operator determination submodule is used to determine at least one database operator used when the database executes the structured query statement according to the execution plan.

[0116] The parameter determination submodule is used to determine the respective sub-hardware resource consumption parameters of each database operator according to at least one database operator, the hardware resource consumption parameters and the table information of the data table corresponding to the structured query statement.

[0117] The information determination submodule is used to determine the hardware resource consumption information according to each database operator and the respective sub-hardware resource consumption parameters of each database operator.

[0118] According to an embodiment of the present invention, the statement determination module 510 includes an initial determination submodule and a query determination submodule.

[0119] The initial determination submodule is used to obtain at least one initial structured query statement in the database script in response to determining that the test request includes a database script for testing the database.

[0120] The query determination submodule is used to determine at least one structured query statement based on at least one initial structured query statement and data stored in the database.

[0121] According to an embodiment of the present invention, the query determination submodule includes a target determination unit and a parameter determination unit.

[0122] The target determination unit is used to query the data stored in the database according to the field name corresponding to the query parameter in response to determining that there is a query parameter with a missing parameter value in the initial structured query statement, and obtain the target data, wherein the query parameter is used to locate the row where the data to be queried corresponding to the initial structured query statement is located.

[0123] The parameter determination unit is used to determine the parameter value of the query parameter in the initial structured query statement based on the target data to obtain the structured query statement.

[0124] According to an embodiment of the present invention, the statement determination module 510 further includes a statement acquisition submodule.

[0125] The statement acquisition submodule is used to obtain structured query statements for testing the database from the test request.

[0126] According to an embodiment of the present invention, the time determination module 540 includes a model prediction submodule.

[0127] The model prediction submodule is used to input the hardware resource configuration parameters, data volume parameters, concurrency parameters and hardware resource consumption information of each structured query statement into the time prediction model to obtain the response time corresponding to the structured query statement.

[0128] According to an embodiment of the present invention, the database response time testing device 500 further includes a target statement determination module and an influencing factor determination module.

[0129] The target statement determination module is used to determine a target structured query statement whose response time is greater than a preset threshold from at least one structured query statement based on the response time corresponding to each structured query statement.

[0130] The influencing factor determination module is used to determine target influencing information from multiple influencing information affecting response time based on a target structured query statement and a data table corresponding to the target structured query statement, wherein the multiple influencing information includes: table index information of the data table, table structure information of the data table and the target structured query statement.

[0131] According to an embodiment of the present invention, any multiple modules among the statement determination module 510, the parameter acquisition module 520, the consumption determination module 530 and the time determination module 540 can be combined into one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present invention, at least one of the statement determination module 510, the parameter acquisition module 520, the consumption determination module 530 and the time determination module 540 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware or in a suitable combination of any of them. Alternatively, at least one of the statement determination module 510, the parameter acquisition module 520, the consumption determination module 530 and the time determination module 540 may be at least partially implemented as a computer program module, which may perform a corresponding function when executed.

[0132] Figure 6 A block diagram of an electronic device suitable for implementing a method for testing database response time according to an embodiment of the present invention is shown.

[0133] like Figure 6 As shown, the electronic device 600 according to an embodiment of the present invention includes a processor 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 to a random access memory (RAM) 603. The processor 601 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 601 may also include an onboard memory for caching purposes. The processor 601 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present invention.

[0134] In RAM 603, various programs and data required for the operation of electronic device 600 are stored. Processor 601, ROM 602 and RAM 603 are connected to each other via bus 604. Processor 601 performs various operations of the method flow according to the embodiment of the present invention by executing the program in ROM 602 and / or RAM 603. It should be noted that the program can also be stored in one or more memories other than ROM 602 and RAM 603. Processor 601 can also perform various operations of the method flow according to the embodiment of the present invention by executing the program stored in the one or more memories.

[0135] According to an embodiment of the present invention, the electronic device 600 may further include an input / output (I / O) interface 605, which is also connected to the bus 604. The electronic device 600 may further include one or more of the following components connected to the input / output (I / O) interface 605: an input portion 606 including a keyboard, a mouse, etc.; an output portion 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 608 including a hard disk, etc.; and a communication portion 606 including a network interface card such as a LAN card, a modem, etc. The communication portion 606 performs communication processing via a network such as the Internet. A drive 610 is also connected to the input / output (I / O) interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage portion 608 as needed.

[0136] The present invention also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiment; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present invention is implemented.

[0137] According to an embodiment of the present invention, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, it may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, according to an embodiment of the present invention, the computer-readable storage medium may include the ROM 602 and / or RAM 603 described above and / or one or more memories other than ROM 602 and RAM 603.

[0138] The embodiment of the present invention also includes a computer program product, which includes a computer program, and the computer program includes a program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the database response time testing method provided by the embodiment of the present invention.

[0139] The computer program executes the above functions defined in the system / device of the embodiment of the present invention when it is executed by the processor 601. According to the embodiment of the present invention, the system, device, module, unit, etc. described above can be implemented by a computer program module.

[0140] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 606, and / or installed from the removable medium 611. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0141] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 606, and / or installed from the removable medium 611. When the computer program is executed by the processor 601, the above functions defined in the system of the embodiment of the present invention are performed. According to the embodiment of the present invention, the system, device, means, module, unit, etc. described above can be implemented by a computer program module.

[0142] According to an embodiment of the present invention, the program code for executing the computer program provided by the embodiment of the present invention can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).

[0143] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0144] It will be appreciated by those skilled in the art that the features described in the various embodiments of the present invention may be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in the present invention. In particular, without departing from the spirit and teachings of the present invention, the features described in the various embodiments of the present invention may be combined and / or combined in various ways. All of these combinations and / or combinations fall within the scope of the present invention.

[0145] The embodiments of the present invention are described above. However, these embodiments are only for the purpose of illustration, and are not intended to limit the scope of the present invention. Although each embodiment is described above, it does not mean that the measures in each embodiment cannot be used in combination advantageously. Without departing from the scope of the present invention, those skilled in the art may make various substitutions and modifications, which should all fall within the scope of the present invention.

Claims

1. A method for testing database response time, characterized in that: The method comprises: In response to receiving a test request, determining at least one structured query statement for testing a database based on the test request, wherein the test request includes a test condition, the test condition includes a hardware resource configuration parameter, a data volume parameter, and a concurrency parameter, and the concurrency parameter represents the concurrency of at least one of the structured query statements; Obtaining the execution plan and hardware resource consumption parameters when the database executes each of the structured query statements; Determining hardware resource consumption information of the database executing each structured query statement based on table information of a data table corresponding to each structured query statement, the execution plan, and the hardware resource consumption parameter, wherein the table information includes: table structure information, table data volume information, and table index information; and Based on the hardware resource consumption information, the hardware resource configuration parameters, the data volume parameters and the concurrency volume parameters, the response time of the database executing each of the structured query statements under the test conditions is determined.

2. The method according to claim 1, characterized in that The determining, based on the table information of the data table corresponding to the structured query statement, the execution plan, and the hardware resource consumption parameter, the hardware resource consumption information of the database executing each structured query statement includes: Determining, according to the execution plan, at least one database operator used by the database when executing the structured query statement; Determining the respective sub-hardware resource consumption parameters of each of the database operators according to at least one of the database operators, the hardware resource consumption parameters, and table information of a data table corresponding to the structured query statement; and The hardware resource consumption information is determined according to each of the database operators and the respective sub-hardware resource consumption parameters of each of the database operators.

3. The method according to claim 1, characterized in that The step of determining at least one structured query statement for testing a database based on the test request comprises: In response to determining that the test request includes a database script for testing the database, obtaining at least one initial structured query statement in the database script; and At least one of the structured query statements is determined based on at least one of the initial structured query statements and the data stored in the database.

4. The method according to claim 3, characterized in that The determining, based on at least one of the initial structured query statements and the data stored in the database, at least one of the structured query statements comprises: In response to determining that there is a query parameter with a missing parameter value in the initial structured query statement, querying the data stored in the database according to the field name corresponding to the query parameter to obtain target data, wherein the query parameter is used to locate the row where the to-be-queried data corresponding to the initial structured query statement is located; and Based on the target data, a parameter value of the query parameter in the initial structured query statement is determined to obtain the structured query statement.

5. The method according to claim 3, characterized in that: The method further comprises: The structured query statement for testing the database is obtained from the test request.

6. The method according to claim 1, characterized in that The step of determining the response time of the database executing each of the structured query statements under the test conditions based on the hardware resource consumption information, the hardware resource configuration parameters, the data volume parameters, and the concurrency volume parameters includes: For each of the structured query statements, the hardware resource configuration parameters, the data volume parameters, the concurrency volume parameters and the hardware resource consumption information of the structured query statement are input into a time prediction model to obtain a response time corresponding to the structured query statement.

7. The method according to any one of claims 1 to 6, characterized in that The method further comprises: Based on the response time corresponding to each of the structured query statements, determining a target structured query statement whose response time is greater than a preset threshold from at least one of the structured query statements; and Based on the target structured query statement and the data table corresponding to the target structured query statement, target impact information is determined from multiple impact information, wherein the multiple impact information includes: table index information of the data table, table structure information of the data table and the target structured query statement.

8. A database response time testing device, characterized in that: The device comprises: A statement determination module, configured to determine, in response to receiving a test request, at least one structured query statement for testing a database based on the test request, wherein the test request includes a test condition, the test condition includes a hardware resource configuration parameter, a data volume parameter, and a concurrency parameter, the concurrency parameter characterizing the concurrency of at least one of the structured query statements; A parameter acquisition module, used to obtain the execution plan and hardware resource consumption parameters when the database executes each structured query statement; a consumption determination module, configured to determine hardware resource consumption information of the database executing each structured query statement based on table information of a data table corresponding to each structured query statement, the execution plan, and the hardware resource consumption parameter, wherein the table information includes: table structure information, table data volume information, and table index information; and The time determination module is used to determine the response time of the database executing each of the structured query statements under the test conditions based on the hardware resource consumption information, the hardware resource configuration parameters, the data volume parameters and the concurrency volume parameters.

9. An electronic device, comprising: one or more processors; a memory for storing one or more computer programs, It is characterized in that the one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program or instruction stored thereon, characterized in that: When the computer program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Task queue execution time prediction method and device and implementation device

    CN109901921A

  • Statement query method and device, electronic equipment and computer readable medium

    CN116775679A

  • Database performance optimization method and device

    CN118535546A

  • Data query method and device

    CN118897844A

  • Method and device for determining distributed keys in distributed database and electronic equipment

    CN119149644A