Database testing method and device, equipment and storage medium
By obtaining and analyzing resource consumption information of database execution expressions, the problem of difficulty in testing database performance differences in the prior art is solved, and the effect of targeted improvement of database performance is achieved.
Patent Information
- Application Number
- CN202410077185.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-18
- Publication Date
- 2025-07-22
AI Technical Summary
The prior art is difficult to effectively test performance differences in database execution transactions, making it difficult to improve database performance.
By obtaining multiple expressions and test data, analyzing the resource consumption information of each operation element of the database, determining performance parameters, and targeting the improvement of poor performance functions and operators.
The analysis of the reasons for poor database performance is realized, and the efficiency of improving database performance is improved.
Smart Images

Figure CN120353697A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular, to a database testing method, apparatus, device, and storage medium. Background Art
[0002] Currently, parameters such as latency and concurrency when a test database executes transactions can be used to understand the performance of the database, so as to improve the reliability and stability of the database. For example, transactions such as grouped queries, nested queries, and sorted queries.
[0003] However, in the case where the performance of the database is poor when executing one or more transactions, this method cannot further test the reasons for the poor performance of the database when executing these transactions, resulting in difficulty in effectively improving the performance of the database. Summary of the Invention
[0004] This application provides a database testing method, apparatus, device, and storage medium for improving the problem of difficult and ineffective database testing.
[0005] In a first aspect, this application provides a database testing method, including: a computer device can obtain a plurality of expressions and first test data. Each expression includes one or more operation elements supported by a first database. The operation elements can be functions or operators. Based on this, the computer device can use the plurality of expressions as a test script to test the first database to obtain performance parameters when the first database executes the expressions, and further support the analysis of the performance of the first database when executing each expression within a transaction. And the computer device can execute a plurality of expressions in the first database to process the first test data, and obtain a plurality of execution information corresponding to the plurality of expressions one by one. Each execution information is used to indicate the resource consumption information when the first database executes the corresponding expression to process the first test data. That is, the computer device can test the resource consumption information when the first database executes each expression. Since each expression is composed of functions or operators, the test result corresponding to the first database can be determined according to the plurality of execution information, that is, the performance parameters when the first database executes each operation element, so as to understand the performance of the first database when executing different functions and operators.
[0006] Based on this, this application can support targeted analysis of the steps executed by functions and operators within a transaction, so as to facilitate targeted improvement of functions and operators with poor performance when the first database executes. Therefore, this application can be used to improve the problem of difficult and ineffective database testing, and can help analyze the reasons for poor database performance, so as to improve the performance of the database.
[0007] In a possible implementation, the method for obtaining multiple expressions specifically includes: obtaining multiple operation elements and multiple data types supported by a first database; determining multiple expressions according to the multiple data types and the multiple operation elements; for different expressions among the multiple expressions, the data types corresponding to the input parameters are different, and / or the included operation elements are different.
[0008] In a possible implementation, the operation element includes a function. The method for determining multiple expressions according to the multiple data types and the multiple operation elements specifically includes: performing a first operation on each function among the multiple functions to obtain multiple expressions; the first operation includes: respectively configuring the multiple data types as the data types of the input parameters of the function to generate multiple first expressions, and the multiple first expressions correspond to the multiple data types one by one; or, determining multiple second expressions corresponding to the function from a preset expression set, and multiple parameter construction statements, and the multiple parameter construction statements correspond to the multiple second expressions one by one, and different parameter construction statements are used to construct input parameters of different data types, and the preset expression set is used to store the expressions and parameter construction statements corresponding to the function.
[0009] In a possible implementation, the operation element includes an operator. The method for determining multiple expressions according to the multiple data types and the multiple operation elements specifically includes: performing a second operation on the multiple operators to obtain multiple expressions; the second operation includes: respectively configuring the multiple data types as the data types of the parameters on the first side of each operator, and respectively configuring the multiple data types as the data types of the parameters on the second side of each operator to generate multiple third expressions; respectively configuring the multiple third expressions on the first side of each operator, and respectively configuring the multiple data types as the data types of the parameters on the second side of each operator to generate multiple fourth expressions.
[0010] In a possible implementation, the method for determining the test result corresponding to the first database according to multiple execution information specifically includes: performing a third operation on each of the multiple operation elements supported by the first database according to the multiple execution information to obtain a test result; the third operation includes: determining the expression including the operation element among the multiple expressions as the test expression corresponding to the operation element; determining the performance parameter when the first database executes the operation element according to the execution information corresponding to the test expression.
[0011] In a possible implementation, the database testing method further includes: determining a plurality of target expressions from a plurality of expressions, and obtaining second test data; the target expressions are used to represent expressions generated by target operation elements and target data types; the target operation elements are used to represent operation elements supported by the first database and the second database; the target data types are used to represent data types supported by the first database and the second database; respectively executing the plurality of target expressions on the second test data in the first database and the second database to obtain a plurality of first execution information corresponding to the first database and a plurality of second execution information corresponding to the second database; determining a comparison test result according to the plurality of first execution information and the plurality of second execution information; the comparison test result is used to represent the performance difference between the first database and the second database when executing the plurality of target expressions.
[0012] In a possible implementation, the first execution information includes the first duration for the target expression to complete execution in the first database. The second execution information includes the second duration for the target expression to complete execution in the second database. The method for determining the comparison test result according to the plurality of first execution information and the plurality of second execution information specifically includes: performing a fourth operation on each target expression among the plurality of target expressions according to the plurality of first execution information and the plurality of second execution information to obtain a comparison test result; the fourth operation includes: when the first duration of the target expression is less than the second duration, increasing the first comparison score corresponding to the first database by a first score value, and increasing the second comparison score corresponding to the second database by a preset score value; the first score value is used to represent the ratio between the first duration of the target expression and the second duration of the target expression; when the first duration of the target expression is greater than the second duration, increasing the first comparison score corresponding to the first database by a preset score value, and increasing the second comparison score corresponding to the second database by a second score value; the second score value is used to represent the ratio between the second duration of the target expression and the first duration of the target expression.
[0013] In a possible implementation, the database testing method further includes: determining a plurality of first target expressions from the plurality of target expressions; the first target expressions are used to represent target expressions whose ratio of the first duration to the second duration is greater than a preset threshold; according to the plurality of first target expressions, determining a first element sequence, the first element sequence includes a plurality of target operation elements arranged in descending order of the number of occurrences; the number of occurrences is used to represent the number of times the target operation element appears in the plurality of first target expressions.
[0014] In a possible implementation, a method for determining a plurality of target expressions from a plurality of expressions specifically includes: respectively verifying the plurality of expressions in a first database and a second database to obtain a first verification result corresponding to the first database and a second verification result corresponding to the second database; the first verification result is used to represent whether each expression in the plurality of expressions is allowed to be executed in the first database; the second verification result is used to represent whether each expression in the plurality of expressions is allowed to be executed in the second database; determining the expressions that meet the preset conditions in the plurality of expressions as the plurality of target expressions; the preset conditions include being allowed to be executed in the first database and being allowed to be executed in the second database.
[0015] In a second aspect, a database testing device is provided, including: an acquisition unit, an execution unit, and a processing unit; the acquisition unit is configured to acquire a plurality of expressions and first test data; the expressions include one or more operation elements supported by the first database; the operation elements include functions or operators; the execution unit is configured to execute the plurality of expressions in the first database to process the first test data to obtain a plurality of execution information; the plurality of execution information corresponds to the plurality of expressions one by one, and the execution information is used to indicate the resource consumption information when the first database executes the expression to process the first test data; the processing unit is configured to determine the test result corresponding to the first database according to the plurality of execution information; the test result includes the performance parameters when the first database executes each operation element.
[0016] In a possible implementation, the acquisition unit is specifically configured to: acquire a plurality of operation elements and a plurality of data types supported by the first database; determine a plurality of expressions according to the plurality of data types and the plurality of operation elements; the data types corresponding to the input parameters of different expressions in the plurality of expressions are different, and / or the included operation elements are different.
[0017] In a possible implementation, the operation element includes a function. The acquisition unit is specifically configured to: perform a first operation on each function in the plurality of functions to obtain a plurality of expressions; the first operation includes: respectively configuring the plurality of data types as the data types of the input parameters of the function to generate a plurality of first expressions, the plurality of first expressions corresponding to the plurality of data types one by one; or, determining a plurality of second expressions corresponding to the function and a plurality of parameter construction statements from a preset expression set, the plurality of parameter construction statements corresponding to the plurality of second expressions one by one, and different parameter construction statements are used to construct input parameters of different data types, and the preset expression set is used to store the expressions and parameter construction statements corresponding to the function.
[0018] In a possible implementation, the operation element includes an operator. The obtaining unit is specifically configured to: perform a second operation on multiple operators to obtain multiple expressions; the second operation includes: respectively configuring multiple data types as the data types of the parameters on the first side of each operator, and respectively configuring multiple data types as the data types of the parameters on the second side of each operator to generate multiple third expressions; respectively configuring multiple third expressions on the first side of each operator, and respectively configuring multiple data types as the data types of the parameters on the second side of each operator to generate multiple fourth expressions.
[0019] In a possible implementation, the processing unit is specifically configured to: according to multiple execution information, perform a third operation on multiple operation elements supported by the first database to obtain a test result; the third operation includes: determining an expression including an operation element in multiple expressions as a test expression corresponding to the operation element; and determining a performance parameter when the first database executes the operation element according to the execution information corresponding to the test expression.
[0020] In a possible implementation, the obtaining unit is further configured to determine multiple target expressions from multiple expressions and obtain second test data; the target expression is used to represent an expression generated by a target operation element and a target data type; the target operation element is used to represent an operation element supported by the first database and the second database; the target data type is used to represent a data type supported by the first database and the second database; the execution unit is further configured to respectively execute multiple target expressions on the second test data in the first database and the second database to obtain multiple first execution information corresponding to the first database and multiple second execution information corresponding to the second database; the processing unit is further configured to determine a comparison test result according to multiple first execution information and multiple second execution information; the comparison test result is used to represent a performance difference when the first database and the second database execute multiple target expressions.
[0021] In a possible implementation, the first execution information includes the first duration for the target expression to complete execution in the first database; the second execution information includes the second duration for the target expression to complete execution in the second database; the processing unit is specifically configured to: according to multiple pieces of first execution information and multiple pieces of second execution information, perform a fourth operation on each target expression among the multiple target expressions to obtain a comparison test result; the fourth operation includes: when the first duration of the target expression is less than the second duration, increasing the first comparison score corresponding to the first database by a first score, and increasing the second comparison score corresponding to the second database by a preset score; the first score is used to represent the ratio between the first duration of the target expression and the second duration of the target expression; when the first duration of the target expression is greater than the second duration, increasing the first comparison score corresponding to the first database by a preset score, and increasing the second comparison score corresponding to the second database by a second score; the second score is used to represent the ratio between the second duration of the target expression and the first duration of the target expression.
[0022] In a possible implementation, the processing unit is further configured to determine multiple first target expressions from the multiple target expressions; the first target expressions are used to represent the target expressions whose ratio between the first duration and the second duration is greater than a preset threshold; the processing unit is further configured to determine a first element sequence according to the multiple first target expressions, the first element sequence includes multiple target operation elements arranged in descending order of the occurrence times; the occurrence times are used to represent the number of times the target operation elements appear in the multiple first target expressions.
[0023] In a possible implementation, the processing unit is specifically configured to: respectively verify the multiple expressions in the first database and the second database to obtain a first verification result corresponding to the first database and a second verification result corresponding to the second database; the first verification result is used to represent whether each expression among the multiple expressions is allowed to be executed in the first database; the second verification result is used to represent whether each expression among the multiple expressions is allowed to be executed in the second database; determine the expressions that meet the preset conditions among the multiple expressions as the multiple target expressions; the preset conditions include being allowed to be executed in the first database and being allowed to be executed in the second database.
[0024] In a third aspect, the present application provides a computer device, which may include: a memory and a processor, the memory is used to store a computer program, and the processor is used to call the computer program to perform the operation steps of the method in the first aspect or any possible implementation manner in the first aspect.
[0025] It should be noted that the memory and the processor described in this application can be integrated on one chip or can be separately provided on different chips. This application does not limit the type of the memory and the setting manner of the memory and the processor.
[0026] In a fourth aspect, this application provides a database testing system, which may include a client and the computer device in the above third aspect. The client can be used to instruct the computer device to test the database. The computer device can, in response to the instruction of the client, execute the operation steps of the method in the first aspect or any possible implementation manner in the first aspect to test the database.
[0027] In a fifth aspect, this application provides a computer-readable storage medium, on which a computer program is stored. When the computer program runs on a computer device, the computer device is caused to execute the operation steps of the method in the first aspect or any possible implementation manner in the first aspect.
[0028] In a sixth aspect, this application provides a computer program product, which, when running on a computer device, causes the operation steps of the method in the first aspect or any possible implementation manner in the first aspect to be executed.
[0029] Any of the above-provided computer devices, database testing systems, computer-readable storage media, computer program products, etc. are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods and will not be elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 is a schematic structural diagram of a testing system provided by an embodiment of this application;
[0031] Figure 2 is a schematic structural diagram of a computer device provided by an embodiment of this application;
[0032] Figure 3 is a schematic flowchart of a database testing method provided by an embodiment of this application;
[0033] Figure 4 is a schematic flowchart of another database testing method provided by an embodiment of this application;
[0034] Figure 5 is a schematic flowchart of another database testing method provided by an embodiment of this application;
[0035] Figure 6 is a schematic flowchart of another database testing method provided by an embodiment of this application;
[0036] Figure 7A flowchart diagram of another database testing method provided by an embodiment of the present application;
[0037] Figure 8 A flowchart diagram of another database testing method provided by an embodiment of the present application;
[0038] Figure 9 A structural diagram of a database testing device provided by an embodiment of the present application. Detailed implementation manners
[0039] Terms such as "first", "second", "third", and "fourth" in the specification, claims, and above-mentioned drawings of the present application are used to distinguish different objects, rather than to limit a specific order.
[0040] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or explanations. Any embodiment or design solution described as "exemplary" or "for example" in the embodiments of the present application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Rather, the use of words such as "exemplary" or "for example" is intended to present relevant concepts in a specific manner.
[0041] The following briefly introduces the terms and technologies related to the embodiments of the present application to facilitate the understanding of readers.
[0042] A database can be a repository that stores and maintains data according to a specific data structure, and can be a collection of a large amount of data stored in a computer for a long time. A database can be created and managed by a database management system (DBMS). The DBMS can be used to perform operations such as adding, deleting, modifying, and querying data, and providing data access services externally.
[0043] A transaction is the basic unit of work in a database and can consist of multiple operations. For example, transactions such as grouped queries, nested queries, and sorted queries.
[0044] An operation can be completed by a structured query language (SQL) statement. For example, an SQL statement for querying data and an SQL statement for inserting data, etc. An SQL statement is also an expression.
[0045] An SQL statement can include one or more operation elements. The operation elements can be functions or operators. For example, functions such as string functions and aggregate functions. Also, for example, conditional operators and logical operators, etc.
[0046] Currently, the performance of a database can be understood by testing parameters such as the latency and concurrency when executing transactions in a test database, so as to improve the reliability and stability of the database, etc.
[0047] This method cannot test the performance of the database when executing functions and operators. In the case where the performance is poor when the database executes one or more transactions, it cannot support further testing of the reasons for the poor performance when the database executes these transactions, resulting in difficulty in effectively improving the performance of the database.
[0048] However, there may be significant differences in the performance of different databases when executing the same function. For example, when the data type of the input parameter of the logarithm (log) function or the natural logarithm (ln) function is of the NUMERIC type, there can be significant differences in the latency of logarithmic calculations by different databases. Without testing at the function level, it is often difficult to discover such differences.
[0049] For this reason, the embodiments of the present application provide a database testing method, apparatus, device, and storage medium. In the database testing method provided by the present application, a computer device can obtain a plurality of expressions and first test data. Each expression includes one or more operation elements supported by a first database. The operation elements can be functions or operators. Based on this, the computer device can use the plurality of expressions as a test script to test the first database to obtain the performance parameters when the first database executes the expressions, and further support the analysis of the performance of each expression within a transaction executed by the first database. And the computer device can execute a plurality of expressions in the first database to process the first test data, and obtain a plurality of execution information corresponding one-to-one to the plurality of expressions. Each execution information is used to indicate the resource consumption information when the first database executes the corresponding expression to process the first test data. That is, the computer device can test the resource consumption information when the first database executes each expression. Since each expression is composed of functions or operators, the test result corresponding to the first database, that is, the performance parameters when the first database executes each operation element, can be determined according to the plurality of execution information, so as to understand the performance of the first database when executing different functions and operators.
[0050] Based on this, the present application can support targeted analysis of the steps executed by functions and operators within a transaction, so as to facilitate targeted improvement of the functions and operators with poor performance when the first database is executed. Therefore, the present application can be used to improve the problem that it is difficult to effectively test the database, and can help analyze the reasons for the poor performance of the database, so as to improve the performance of the database.
[0051] This database testing method is applied to the computer device within the testing system. The following describes the testing system provided by the embodiments of the present application.
[0052] Figure 1 It is a schematic diagram of a testing system 100 provided by the embodiments of the present application. The testing system 100 includes a front-end device 10 and a computer device 20. The front-end device 10 and the computer device 20 can be connected through a wired network and a wireless network.
[0053] Optionally, Figure 1 the front-end device 10 and the computer device 20 in can be functional modules integrated within the same device, or two independently provided devices. The present application does not limit this.
[0054] It is easy to understand that when the front-end device 10 and the computer device 20 are functional modules integrated within the same device, the communication method between the front-end device 10 and the computer device 20 is the communication between internal modules of the device. In this case, the communication process between the two is the same as "the communication process between the front-end device 10 and the computer device 20 when they are independently provided".
[0055] For the sake of easy understanding, the present application mainly takes the case where the front-end device 10 and the computer device 20 are independently provided as an example for description.
[0056] Figure 1 The front-end device 10 in can be configured with an input module, a sending module, a display module, etc. The input module can be a peripheral such as a keyboard or a mouse, and can be used to support the staff to edit test data and test instructions, etc. The test data is the data to be processed when testing the database. The test instruction can be used to indicate the database to be tested, etc. The sending module can be a communication interface, etc., and can be used to send the test data and test instructions edited by the staff to the computer device 20, etc. The display module can be used to display the test results, etc.
[0057] Figure 1 The computer device 20 in can be configured with one or more databases. Different databases can store data according to different data structures, or process data based on different processing logics. The computer device 20 can also be configured with a database performance testing service. The database performance testing service can be used to generate expressions for testing, execute the expressions in different databases, and record the running information when different databases execute the expressions, etc. For example, the computer device 20 can receive the test data and test instructions, etc. from the front-end device 10, generate expressions through the database performance testing service, and execute the expressions in the database corresponding to the test instruction to process the test data for database testing.
[0058] In a possible way, the database performance testing service may have a generation function, a verification function, and an execution function. The generation function can be used to construct test scripts in test cases, that is, SQL statements (i.e., expressions) for testing. The verification function can be used to verify whether the constructed expression is correct, that is, whether it can be executed by the database. The execution function can be used to execute the verified expression in the database and record resource consumption information during the execution process, etc.
[0059] In a possible way, the database performance testing service can be a Java-based application and can be implemented in the form of Java source code or a Java Archive (JAR) file after packaging the Java source code, etc. Moreover, the database performance testing service can use the driver provided by the database to establish a connection with the database, thereby supporting the performance testing of the database.
[0060] Optionally, the front-end device 10 and the computer device 20 can be terminals, can also be servers, or can be other types of computer devices with the above functions. Figure 1 Shown in the figure is an example of the device form of the front-end device 10 and the computer device 20, which does not limit it.
[0061] When the front-end device 10 and the computer device 20 are terminals, the terminal can be a personal computer such as a desktop computer, a tablet computer, and a laptop computer, or can also be a remote terminal, a user terminal (terminal equipment, TE), a mobile device, etc. This application does not limit the form of the terminal. The device for implementing the functions of the terminal can be a terminal or can also be a device capable of supporting the terminal to implement the functions, such as a chip system. The device can be installed in the terminal or used in matching with the terminal. In the embodiments of this application, the chip system can be composed of chips or can also include chips and other discrete devices.
[0062] When the front-end device 10 and the computer device 20 are servers, the server can be a single server, or can also be a server cluster composed of multiple servers. In some implementation manners, the server cluster can also be a distributed cluster. This application does not limit the form of the server.
[0063] It should be noted that Figure 1 The shown test system is only an example, which does not limit the system architecture applicable to the database testing method provided by the embodiments of this application. For example, the test system can include multiple front-end devices 10. Also, for example, the test system can include multiple computer devices 20.
[0064] Figure 2Schematic diagram of the hardware structure of a computer device 20 provided by an embodiment of the present application. The computer device 20 may include a processor 2001, a memory 2002, and a communication interface 2003. The processor 2001, the memory 2002, and the communication interface 2003 may be interconnected through a bus 2004.
[0065] The processor 2001 may be one or more CPUs. When the processor 2001 is a single CPU, the CPU may be a single-core CPU or a multi-core CPU. The processor 2001 may be used to read data stored in the memory 2002 and perform database test operations, etc.
[0066] The memory 2002 may be a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), or a compact disc read-only memory (CD-ROM). The memory 2002 is used to store test data, related program codes, etc.
[0067] The communication interface 2003 is used to receive / send data in response to instructions from the processor 2001 and the memory 2002.
[0068] The embodiments of the present application do not limit the number of these devices. For example, the computer device 20 may include one or more processors 2001. Another example is that the computer device 20 may include one or more memories 2002, etc.
[0069] Next, in combination with Figure 1 the test system shown or Figure 2 the computer device shown, the database test method provided by the embodiments of the present application will be described.
[0070] Figure 3 Schematic diagram of the process of a database test method provided by an embodiment of the present application. Figure 3 The method shown can be applied to Figure 1 the computer device in the test system shown. The computer device may specifically include Figure 2 the components shown. As Figure 3 shown, the database test method may include: S301 - S303.
[0071] S301. The computer device obtains a plurality of expressions and first test data.
[0072] Among them, each of the multiple expressions may include one or more operation elements. The operation elements may be functions or operators supported by the first database for processing. That is, an expression may include one function or multiple functions. Alternatively, an expression may include one operator or multiple operators.
[0073] In a possible way, the first test data may include multiple data sets. The multiple data sets may correspond one-to-one to multiple data types supported by the first database. One data set may include multiple data of the data type corresponding to the one data set. The data types supported by the first database for processing may be integer type, floating-point type, boolean type, etc.
[0074] In a possible implementation, the computer device may be configured with a first database and a storage module. The first database may be a relational database such as MySQL, or a non-relational database such as a key-value database and a columnar database. The storage module may pre-store multiple expressions and the first test data. The computer device may read the multiple expressions and the first test data from the storage module to further test the first database.
[0075] In a possible implementation, the computer device may exhaustively list the multiple functions and multiple data types supported by the first database, that is, configure the input parameters of each function with multiple data types to obtain multiple function expressions corresponding to each function. The multiple data types correspond one-to-one to the multiple function expressions. The computer device may also exhaustively list the multiple operators and multiple data types supported by the first database to obtain multiple operator expressions corresponding to each operator. Based on this, the computer device may obtain multiple expressions including multiple function expressions and multiple operator expressions.
[0076] S302. The computer device processes the first test data by executing multiple expressions in the first database to obtain multiple execution information.
[0077] Among them, the multiple execution information may correspond one-to-one to the multiple expressions. The execution information is used to indicate the resource consumption information when the first database executes the corresponding expression to process the first test data.
[0078] In a possible way, the resource consumption information may include time resource consumption information, computing resource consumption information, storage resource consumption information, etc. The time resource consumption information is the time consumed during the execution process, that is, the latency of the execution process. The computing resource consumption information is the computing resources consumed during the execution process. The storage resource consumption information is the storage resources consumed during the execution process.
[0079] In a possible implementation, for any one of the multiple expressions, the computer device may execute the any one expression in the first database to process the data in the first test data corresponding to the data type of the input parameter of the any one expression. During this processing, the computer device may count the resource consumption information when executing the any one expression in the first database.
[0080] S303. The computer device determines the test result corresponding to the first database according to multiple execution information.
[0081] Among them, the test result may include the performance parameters when the first database executes each operation element, and is used to indicate the performance when the first database executes each operation element.
[0082] In a possible implementation, for any one of the multiple operation elements, the computer device may determine at least one execution information corresponding to the any one operation element from the multiple execution information according to the expression including the any one operation element. Furthermore, the computer device may determine the performance parameter when the first database executes the any one operation element based on the at least one execution information. For example, the computer device may determine the average value or the maximum value of the time resource consumption information in the at least one execution information as the latency when the first database executes the any one operation element.
[0083] Based on the descriptions of S301 - S303 above, in the database testing method provided in this application, the computer device may obtain multiple expressions and the first test data, and execute the multiple expressions in the first database to process the first test data, obtaining multiple execution information corresponding one by one to the multiple expressions. Since each expression includes one or more operation elements (such as functions or operators) supported by the first database, and each execution information is used to indicate the resource consumption information when the first database executes the corresponding expression to process the first test data, therefore, the computer device may determine the test result corresponding to the first database, that is, the performance parameters when the first database executes each operation element, so as to understand the performance when the first database executes different functions and operators.
[0084] Based on this, this application can support targeted analysis of the steps executed by functions and operators within a transaction, thereby facilitating targeted improvement of the functions and operators with poor performance when the first database executes. Therefore, this application can be used to improve the problem that it is difficult to effectively test a database, and can help analyze the reasons for the poor performance of the database, so as to improve the performance of the database.
[0085] In another embodiment, in order to obtain multiple expressions to test the performance of the first database when executing functions and operators, an alternative implementation provided by the embodiments of the present application includes: S401 - S402.
[0086] S401. The computer device obtains multiple operation elements and multiple data types supported by the first database.
[0087] In one possible implementation, the computer device can determine multiple functions, multiple operators, and multiple data types supported by the first database by reading the system table of the first database.
[0088] S402. The computer device determines multiple expressions based on the multiple data types and multiple operation elements.
[0089] In one possible way, the operation elements included in different expressions among the multiple expressions may also be different, and the data types corresponding to the input parameters of different expressions may be the same or different. Testing the first database based on these expressions can facilitate understanding the performance of the first database when executing different operation elements.
[0090] In one possible way, the operation elements included in different expressions among the multiple expressions may be the same, and the data types corresponding to the input parameters of different expressions may be different. Testing the first database based on these expressions can facilitate understanding the performance of the first database when executing the same operation element to process data of different data types.
[0091] Exemplarily, there are preset expression 1 and expression 2. Expression 1 and expression 2 may be composed of the same log function. The data type of the input parameter of the log function in expression 1 may be an integer type. The data type of the input parameter of the log function in expression 2 may be a floating-point type. Testing the first database based on expression 1 and expression 2 can facilitate understanding the performance of the first database when executing the log function to process integer data and floating-point data.
[0092] In one possible implementation, when the computer device determines an expression based on the multiple data types and multiple functions supported by the first database, it can perform a first operation on each function among the multiple functions.
[0093] For a function with one input parameter (i.e., a single-input parameter function), when the computer device executes the first operation formula, multiple data types can be respectively configured as the data types of the input parameters of the function to generate multiple first expressions. Among them, the multiple first expressions can correspond one-to-one with the multiple data types. In other words, the multiple data types can be respectively exhausted with the single-input parameter function to generate multiple first expressions. In a first expression, the data type of the input parameter of the single-input parameter function is any one of the multiple data types.
[0094] For a function with multiple input parameters (i.e., a multi-input parameter function), when the computer device executes the first operation, multiple second expressions corresponding to the function and multiple parameter construction statements corresponding one-to-one with the multiple second expressions can be determined from a preset expression set. Among them, the preset expression set can be used to store the expressions and parameter construction statements corresponding to the function. In the preset expression set, one expression can be correspondingly configured with one parameter construction statement. The one parameter construction statement can be used to construct the input parameters of the one expression of multiple data types. And different parameter construction statements in the preset expression set can be used to construct input parameters of different data types.
[0095] In a possible implementation, when the computer device determines an expression according to multiple data types and multiple operators supported by the first database, a second operation can be performed on each of the multiple operators.
[0096] Among them, the second operation can include: respectively configuring multiple data types as the data types of the parameters on the first side of each operator, and respectively configuring multiple data types as the data types of the parameters on the second side of each operator to generate multiple third expressions. Respectively configuring the multiple third expressions on the first side of each operator, and respectively configuring multiple data types as the data types of the parameters on the second side of each operator to generate multiple fourth expressions.
[0097] The first side and the second side can be the left side and the right side of the operator. A third expression can include one operator and two input parameters. The data type of the input parameter on the left side of the one operator can be any one of the multiple data types, and the data type of the input parameter on the right side of the one operator can also be any one of the multiple data types.
[0098] A fourth expression can include two operators and three input parameters. The data type of the input parameter on the left side of any one of the two operators can be any one of the multiple data types, and the data type of the input parameter on the right side of any one of the two operators can also be any one of the multiple data types.
[0099] Exemplarily, as Figure 4 shown, in the case of performing the second operation, an optional implementation manner is provided in an embodiment of the present application. The database testing method may include: S4021 - S4029.
[0100] S4021. The computer device initializes the current layer number.
[0101] Wherein, the current layer number is used to indicate the number of operators in the expression.
[0102] In a possible way, when the computer device initializes the current layer number, it may assign the current layer number to 1.
[0103] S4022. The computer device generates all expressions of the current layer number.
[0104] In a possible way, when the current layer number is 1, the computer device may generate a third expression whose number of included operators is 1. The left and right sides of the operator in the third expression may be defined as any data type among multiple data types. In other words, the computer device may enumerate all data types on the left and right sides of each operator.
[0105] S4023. The computer device verifies all expressions.
[0106] In a possible way, considering that the generated expressions may not be correctly executed by the first database, in order to avoid the problem that expressions cannot be executed during the testing process, the computer device may verify all expressions of the current layer number through the verification function of the configured database testing service. For example, the computer device may execute each expression in the first database to process a preset piece of data to verify whether the generated expressions can be correctly executed.
[0107] S4024. The computer device obtains the expressions that pass the verification.
[0108] In a possible way, the computer device may discard the expressions that do not pass the verification and retain the expressions that pass the verification.
[0109] S4025. The computer device randomly screens the expressions that pass the verification.
[0110] In a possible way, the computer device may randomly screen the expressions that pass the verification, avoiding the problem that the number of expressions enumerated may be too large when there are many operators and data types, and improving the testing efficiency.
[0111] S4026. The computer device stores the screened expressions into the result set.
[0112] In a possible way, the computer device can store the filtered expressions into the result set, that is, determine the filtered expressions as partial expressions among multiple expressions.
[0113] S4027. The computer device increments the current layer number by 1.
[0114] In a possible way, the computer device can increment the current layer number by 1, that is, assign the current layer number as 2.
[0115] S4028. Whether the current layer number of the computer device is greater than the exhaustive layer number.
[0116] Among them, the exhaustive layer number can be preset and used to represent the maximum number of operators that an expression can include. For example, the exhaustive layer number can be 3, 5, etc.
[0117] In a possible way, after the computer device re - assigns the current layer number, it can determine whether the current layer number is greater than the exhaustive layer number.
[0118] If the computer device determines that the current layer number is less than or equal to the exhaustive layer number, the computer device can repeatedly execute S4022 - S4027. That is, the computer device can, based on the third expression, generate all expressions with the current layer number of 2, that is, generate the fourth expression with the number of included operators being 2. Furthermore, the computer device can increment the current layer number by 1 again, that is, assign the current layer number as 3. Subsequently, when the current layer number is not greater than the exhaustive layer number, the computer device can further generate all expressions with the current layer number of 3 based on the fourth expression.
[0119] S4029. The computer device ends the execution of the second operation.
[0120] If the computer device determines that the current layer number is greater than the exhaustive layer number, the computer device stops executing the second operation and obtains the result set, that is, the set of expressions used to test the performance of the first database when executing multiple operators. Based on this, in a bottom - up manner (that is, the number of operators increases from less to more), multiple expressions can be obtained by exhausting multiple operators and multiple data types, so as to comprehensively test the performance of the first database.
[0121] Based on the above description, it can be known that the computer device can obtain the functions, operators, and data types supported by the first database, and further generate multiple expressions. Since the data types corresponding to the input parameters of different expressions are different, and / or the included operation elements are different, that is, the multiple expressions can be any combination of functions and data types, or any combination of operators and data types. Therefore, this application can support the exhaustive combination of operation elements and data types, can efficiently and comprehensively generate test statements in test cases, and can cover various basic services that may exist in the actual operation scenario of the first database, so as to improve the comprehensiveness of testing the first database. Moreover, compared with the method of manually constructing test cases during testing, this application can support the implementation of one-key automatic generation of test cases, avoiding the problem of low efficiency caused by manually constructing test statements, and can simplify the process of testing the database.
[0122] In another embodiment, when the computer device determines the test result corresponding to the first database according to multiple execution information, an optional implementation manner provided by the embodiments of this application includes: S501.
[0123] S501. The computer device performs a third operation on each of the multiple operation elements supported by the first database according to the multiple execution information, and obtains a test result.
[0124] Among them, the third operation may include: determining the expression including the operation element in the multiple expressions as the test expression corresponding to the operation element. According to the execution information corresponding to the test expression, determining the performance parameter when the first database executes the operation element.
[0125] For example, for any one of the multiple operation elements, if an expression includes the any one operation element, then the one expression can be the test expression of the any one operation element. It should be understood that any one operation element may correspond to one or more test expressions. The execution information obtained by executing the one or more test expressions in the first database can be used to determine the performance when the first database executes the any one operation element. Furthermore, the computer device can determine the performance parameter when the first database executes the any one operation element according to the execution information corresponding to the one or more test expressions.
[0126] In a possible implementation, when there are multiple test expressions for any one of the operation elements, the computer device may determine the performance parameters when the first database executes any one of the operation elements according to multiple execution information corresponding to the multiple test expressions one by one. For example, the computer device may determine the average value, median value, or maximum value of the time resource consumption indicated by the multiple execution information as the time-consuming parameter when the first database executes any one of the operation elements. For another example, the computer device may determine the average value, median value, or maximum value of the computing resource consumption indicated by the multiple execution information as the energy consumption parameter when the first database executes any one of the operation elements, etc.
[0127] In another embodiment, as Figure 5 shown, it is a schematic flowchart of a database testing method provided by an embodiment of the present application. To test the performance difference between the first database and the second database, the database testing method provided by the embodiment of the present application may further include: S601 - S603.
[0128] S601. The computer device determines multiple target expressions from multiple expressions and obtains second test data.
[0129] Among them, the target expression can be used to represent an expression generated by a target operation element and a target data type. The target operation element can be used to represent the operation elements supported by the first database and the second database. The target data type can be used to represent the data types supported by the first database and the second database, and can be one or more data types.
[0130] In a possible way, the target operation element can be executed in the first database and the second database, and the same test data of the target data type can be processed to test the performance difference between the first database and the second database. The target operation element can be a target function or a target operator. The target function is a function supported by both the first database and the second database, that is, the functions with the same name in the first database and the second database. The target operator is an operator supported by both the first database and the second database.
[0131] In one possible implementation, after a computer device obtains multiple functions supported by a first database, it can verify these multiple functions in a second database to determine the functions supported by the second database among these multiple functions, i.e., target functions. When verifying these multiple functions, the computer device can call each function among these multiple functions in the second database and determine whether each function is supported by the second database based on whether the call is successful. For example, for each function among these multiple functions, the computer device can execute call function statements such as "select func()" or "select func() from dual" in the second database and determine whether each function is supported by the second database based on different error codes.
[0132] Moreover, after a computer device obtains multiple data types supported by a first database, it can verify these multiple data types in a second database to determine the data types supported by the second database among these multiple data types, i.e., target data types. When verifying these multiple data types, the computer device can create data tables for each data type among these multiple data types in the second database and determine whether each data type is supported by the second database based on whether the creation is successful. For example, the computer device can execute statements for creating data tables such as "create table typeverifier(col1 type_to_be_tested)" in the second database. Here, "type_to_be_tested" is the data type to be verified. If a data table of a data type can be successfully created in the second database, it can indicate that the second database supports this data type, i.e., the target data type. Otherwise, it can indicate that the second database does not support this data type. Furthermore, the computer device can determine the expressions composed of target functions and target data types among multiple expressions as target expressions.
[0133] In one possible implementation, a computer device can verify multiple expressions in a first database and a second database respectively, obtaining a first verification result corresponding to the first database and a second verification result corresponding to the second database. Among them, the first verification result can be used to represent whether each expression among multiple expressions is allowed to be executed in the first database. The second verification result can be used to represent whether each expression among multiple expressions is allowed to be executed in the second database. Furthermore, the computer device can determine the expressions that meet the preset conditions among multiple expressions as multiple target expressions. The preset conditions can include being allowed to be executed in the first database and being allowed to be executed in the second database.
[0134] Such as Figure 6As shown, in the case of validating an expression, an alternative implementation manner is provided in an embodiment of the present application. The database testing method may include: S6011 - S6014.
[0135] S6011. The computer device obtains a plurality of expressions.
[0136] S6012. The computer device determines whether each expression passes the verification function verification.
[0137] In a possible manner, when the computer device verifies a plurality of expressions through the verification function, the computer device may verify the plurality of expressions in the first database and the second database respectively.
[0138] S6013. The computer device determines the expressions that pass the verification as target expressions.
[0139] S6014. The computer device discards the expressions that do not pass the verification.
[0140] In a possible manner, in S6012, that is, when the computer device verifies a plurality of expressions through the verification function, the computer device may verify the plurality of expressions in the first database and the second database respectively.
[0141] For example, the computer device may directly execute the plurality of expressions in the first database and the second database through a Java Database Connectivity (JDBC) service to process preset test data. Among them, the preset test data includes data of multiple data types, and the data of each data type may be a row of data to facilitate the quick completion of the verification process. If an expression can be executed by both the first database and the second database at the same time, it may indicate that the expression is supported by both the first database and the second database at the same time and is a target expression. If an expression fails to execute in the first database and / or the second database, it may indicate that the expression cannot be supported by both the first database and the second database at the same time. In this case, the computer device may obtain the execution error of the expression through an exception handling logic and discard the expression. The process of the computer device executing a plurality of expressions in the first database or the second database may be specifically implemented by a first program instruction. The first program instruction is as follows:
[0142]
[0143]
[0144] For another example, the computer device can create data tables for storing multiple expressions in the first database and the second database respectively, and use stored procedures to execute the multiple expressions in sequence to screen the target expressions that pass the verification through the exception handling logic. The method for the computer device to call the stored procedure in the first database or the second database can be specifically implemented by the second program instruction. The second program instruction is as follows:
[0145]
[0146] Based on this, the present application can support the verification of the generated expressions, can accurately screen out the expressions supported by the database for execution, helps to achieve one-key automatic semantic verification of the expressions, and improves the correctness of the automatically generated test statements.
[0147] In one possible way, for each target data type, the second test data can include a large amount of data to avoid the test time being too short to compare when the data volume is small, so as to accurately test the first database and the second database. For example, there can be 10,000 pieces of data for each target data type.
[0148] S602. The computer device processes the second test data by executing multiple target expressions in the first database and the second database respectively, and obtains multiple first execution information corresponding to the first database and multiple second execution information corresponding to the second database.
[0149] Among them, the multiple target expressions can be in one-to-one correspondence with the multiple first execution information, and can also be in one-to-one correspondence with the multiple second execution information. The first execution information can be used to indicate the resource consumption information when the first database executes the target expression to process the second test data. The second execution information can be used to indicate the resource consumption information when the second database executes the target expression to process the second test data.
[0150] In one possible way, as Figure 7 shown, in the case of executing multiple target expressions, the embodiments of the present application provide an optional implementation manner. The database system testing method may include: S6021 - S6023.
[0151] S6021. The computer device obtains multiple target expressions.
[0152] S6022. The computer device performs execution through the execution function.
[0153] In one possible way, the computer device can test the execution function of the database testing service by executing multiple target expressions in the first database and the second database respectively. For example, the computer device can call the JDBC service through the execution function to execute multiple target expressions in the first database and the second database respectively.
[0154] S6023. The computer device records the first execution information and the second execution information corresponding to each target expression.
[0155] In one possible way, the computer device can record the first execution information and the second execution information corresponding to each target expression. For example, the computer device can record the duration of each target expression executed by the first database and the duration of each target expression executed by the second database.
[0156] In one possible way, in order to more accurately test the performance of the first database or the second database when executing target expressions, batch execution can be performed on each type of target data type in the second test data.
[0157] For example, the computer device can execute the function call statement "select abs(integer_column)from data_table" in the first database. Among them, "integer_column" is a column in "data_table", that is, the column storing data of integer type in the data table corresponding to the second test data. This function call statement is used to test the performance of the first database when executing the function named abs to process data of integer type.
[0158] S603. The computer device determines the comparison test result according to the multiple first execution information and the multiple second execution information.
[0159] Among them, the comparison test result can be used to characterize the performance difference between the first database and the second database when executing multiple target expressions.
[0160] In one implementable way, the computer device can also divide the multiple target expressions into target expressions composed of functions and target expressions composed of operators, and further determine the first comparison test result according to the first execution information and the second execution information corresponding to the target expressions composed of functions, and determine the second comparison test result according to the first execution information and the second execution information corresponding to the target expressions composed of operators. Among them, the first comparison test result can be used to characterize the performance difference between the first database and the second database when executing multiple functions. The second comparison test result can be used to characterize the performance difference between the first database and the second database when executing multiple operators.
[0161] In one possible implementation, each of the multiple first execution information may include the first duration for the corresponding target expression to be completed in the first database. Each of the multiple second execution information may include the second duration for the corresponding target expression to be completed in the second database.
[0162] When determining the comparison test result based on the multiple first execution information and the multiple second execution information, the computer device may perform a fourth operation on each of the multiple target expressions according to the multiple first durations and the multiple second durations to obtain the comparison test result. Alternatively, the computer device may also compare the total duration obtained by summing the multiple first durations with the total duration obtained by summing the multiple second durations to obtain the comparison test result, etc.
[0163] Among them, the fourth operation includes: when the first duration of the target expression is less than the second duration, increasing the first comparison score corresponding to the first database by the first score value, and increasing the second comparison score corresponding to the second database by a preset score value. When the first duration of the target expression is greater than the second duration, increasing the first comparison score corresponding to the first database by the preset score value, and increasing the second comparison score corresponding to the second database by the second score value. Optionally, when the first duration of the target expression is equal to the second duration, the first comparison score and the second comparison score may remain unchanged or increase by the same score value.
[0164] The first score value may be used to represent the ratio between the first duration of the target expression and the second duration of the target expression. The second score value may be used to represent the ratio between the second duration of the target expression and the first duration of the target expression. The initial values of the first comparison score and the second comparison score may be zero. The preset score value may be 1 or 2, etc.
[0165] In other words, if the execution duration of a target expression in the first database is less than that in the second database, it may indicate that the performance of the first database in executing the target expression is better than that of the second database. Then, for the target expression, the first comparison score of the first database may be increased by the preset score value, and the second comparison score of the second database may be increased by the ratio of the first duration to the second duration of the target expression. Compared with the value increased by the second comparison score of the second database, the value increased by the first comparison score of the first database is higher. Based on this, the first comparison score and the second comparison score obtained after performing the fourth operation on all the multiple target expressions may be used to represent the performance difference in terms of time consumption when the first database and the second database execute the multiple target expressions. Based on this, the present application can support the comparison test of the basic performance of different databases, and can compare the time delay when different databases execute expressions, and can effectively test the performance bottleneck of the databases.
[0166] In a possible way, the first comparison score and the second comparison score can be multiplied by 100 and divided by the number of multiple target expressions respectively for percentage conversion, so as to intuitively reflect the performance difference between the first database and the second database in terms of time consumption. For example, for the target expressions composed of operators, the first comparison score of the first database can be 61.2, and the second comparison score of the second database can be 85.3.
[0167] In a possible way, if the first comparison score is less than the second comparison score, it can indicate that the performance of the first database when executing multiple target expressions is lower than that of the second database when executing multiple target expressions. In this case, the computer device can also determine multiple first target expressions from the multiple target expressions. The first target expression can be used to characterize the target expression whose ratio of the first duration to the second duration is greater than a preset threshold. The preset threshold can be 2 or 3, etc. Based on this, all target expressions whose ratio of the first duration to the second duration is at or above the preset threshold can be filtered out from the multiple target expressions, that is, the target expressions whose execution time in the first database is much greater than that in the second database are filtered out.
[0168] Furthermore, the computer device can determine a first element sequence according to the multiple first target expressions. For example, the computer device can determine the number of occurrences of each target operation element in the multiple target operation elements in the multiple first target expressions, and obtain the corresponding number of occurrences of the multiple target operation elements one by one. And the computer device can sort the multiple target operation elements in descending order of the number of occurrences to obtain a first element sequence, so as to reflect that the first database may have poor performance when executing the operation elements with a larger number of occurrences, resulting in longer time consumption when executing multiple first target expressions.
[0169] Alternatively, the computer device can also sort the multiple first target expressions in descending order of the corresponding first duration to obtain a sorting result. And the computer device can add the multiple first durations corresponding to the multiple first target expressions one by one, and the multiple second durations corresponding to the multiple first target expressions one by one to the sorting result to obtain a first comparison sequence, so as to intuitively reflect the difference in time consumption between the first database and the second database when executing multiple first target expressions.
[0170] Exemplarily, the first comparison sequence can be as shown in Table 1 below.
[0171] Table 1
[0172]
[0173] Based on this, the present application can support comparative testing between different databases in terms of function and operator execution dimensions, achieving a comprehensive scan of the performance of the basic functions of database operation, and improving the scalability of database performance testing. Moreover, the present application can compare the test results of different databases, conduct comparative evaluation, and determine the expressions (i.e., SQL statements) with higher execution time consumption, so as to quickly locate the reasons for poor database performance.
[0174] As Figure 8 shown, in the case of conducting comparative testing on the first database and the second database, the embodiment of the present application provides a schematic flowchart of another database testing method. This database testing method may include: S701 - S706.
[0175] S701. The computer device obtains preset test data.
[0176] Among them, the preset test data may include one row of data for each data type among multiple data types.
[0177] S702. The computer device generates multiple expressions.
[0178] In a possible way, the computer device may generate multiple expressions according to multiple functions, multiple operators, and multiple data types supported by the first database or the second database.
[0179] S703. The computer device verifies the multiple expressions, discards the expressions that fail to pass the verification, and obtains multiple target expressions.
[0180] In a possible way, the computer device may verify the multiple expressions in the first database and the second database based on the preset test data, discard the expressions that fail to pass the verification, and obtain multiple target expressions.
[0181] S704. The computer device obtains second test data.
[0182] Among them, the second test data may include a large amount of data for each data type.
[0183] S705. The computer device executes the multiple target expressions in the first database and the second database.
[0184] In a possible way, the computer device may execute the multiple target expressions in the first database and the second database to process the second test data, and obtain multiple first execution information and multiple second execution information.
[0185] S706. The computer device outputs the comparative test result.
[0186] In one possible way, the computer device may determine and output a comparison test result based on multiple first execution information and multiple second execution information. Based on this, the present application can support comparing the basic performance differences between different databases.
[0187] The above mainly introduces the solution provided by the embodiments of the present application from the perspective of methods. To implement the above functions, it includes the corresponding hardware structures and / or software modules for executing each function. Those skilled in the art should easily realize that, combining the units and algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed in the way of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.
[0188] The embodiments of the present application can divide the computer device into functional modules according to the above method examples. For example, each functional module can be divided corresponding to each function, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware or in the form of a software functional module. It should be noted that the division of modules in the embodiments of the present application is illustrative, only a logical function division, and there may be other division methods in actual implementation.
[0189] In the above text, in combination with Figures 3 to 8 , the database test method provided by the embodiments of the present application has been described in detail. Next, in combination with Figure 9 , the database test device provided by the embodiments of the present application will be described.
[0190] Figure 9 FIG. 30 is a schematic structural diagram of a database test device 30 provided by an embodiment of the present application. The database test device 30 can be used to execute Figures 3 - 8 any one of the database test methods shown in the drawings. When the database test device 30 is a virtual device, the database test device 30 can be deployed on a computer device in the test system. The database test device 30 can include functional units for executing the database test methods described in any of the above embodiments. For example, the database test device 30 can include: an acquisition unit 3001, an execution unit 3002, a processing unit 3003, etc. In combination with Figure 3 , the acquisition unit 3001 can be used to execute S301. The execution unit 3002 can be used to execute S302, and the processing unit 3003 can be used to execute S303.
[0191] For the explanations of relevant contents and descriptions of beneficial effects in this embodiment, reference can be made to the above method embodiments, which will not be elaborated here. As an example, in combination with Figure 1 , the database testing device 30 in this embodiment may be Figure 1 the computer device 20. The above-mentioned obtaining unit 3001, executing unit 3002, processing unit 3003, etc. can be used to implement Figure 1 each function possessed by the computer device 20 shown in
[0192] As an example, in combination with Figure 2 , the database testing device 30 in this embodiment may be Figure 2 the computer device 20. Some or all of the above-mentioned modules such as the obtaining unit 3001, executing unit 3002, and processing unit 3003 can also be implemented by the processor 2001.
[0193] It should be understood that the database testing device 30 of the embodiments of the present application can be implemented by an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The above PLD can be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof. When implementing Figures 3 to 7 the database testing method shown by software, the database testing device 30 and its various modules can also be software modules.
[0194] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using a software program, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer execution instructions are loaded and executed on a computer, the processes or functions according to the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center in a wired manner (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or a wireless manner (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or a data center that includes one or more media integrated therein. The available medium can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)), etc.
[0195] As described above, the above are only the specific embodiments of the present application. Those skilled in the art of this technology can think of variations or substitutions based on the specific embodiments provided by the present application, and all should be covered within the protection scope of the present application.
Claims
1. A database testing method, characterized in that, Including: Obtaining a plurality of expressions and first test data; the expressions include one or more operation elements supported by a first database; The operation elements include functions or operators; Executing the plurality of expressions in the first database to process the first test data, obtaining a plurality of execution information; the plurality of execution information corresponds to the plurality of expressions one by one, and the execution information is used to indicate resource consumption information when the first database executes the expression to process the first test data; Determining a test result corresponding to the first database according to the plurality of execution information; the test result includes performance parameters when the first database executes each operation element.
2. The database testing method according to claim 1, wherein The obtaining a plurality of expressions includes: Obtaining a plurality of operation elements and a plurality of data types supported by the first database; Determining the plurality of expressions according to the plurality of data types and the plurality of operation elements; the data types corresponding to the input parameters of different expressions in the plurality of expressions are different, and / or the included operation elements are different.
3. The database testing method according to claim 2, wherein The operation elements include the functions, and the determining the plurality of expressions according to the plurality of data types and the plurality of operation elements includes: Performing a first operation on each of the plurality of functions to obtain the plurality of expressions; The first operation includes: respectively configuring the plurality of data types as the data types of the input parameters of the function to generate a plurality of first expressions, the plurality of first expressions corresponding to the plurality of data types one by one; or, determining a plurality of second expressions corresponding to the function and a plurality of parameter construction statements from a preset expression set, the plurality of parameter construction statements corresponding to the plurality of second expressions one by one, and different parameter construction statements are used to construct input parameters of different data types, and the preset expression set is used to store expressions and parameter construction statements corresponding to the function.
4. The database testing method according to claim 2, wherein The operation elements include the operators, and the determining the plurality of expressions according to the plurality of data types and the plurality of operation elements includes: Performing a second operation on the plurality of operators to obtain the plurality of expressions; The second operation includes: respectively configuring the plurality of data types as the data types of the parameters on the first side of each operator, and respectively configuring the plurality of data types as the data types of the parameters on the second side of each operator to generate a plurality of third expressions; respectively configuring the plurality of third expressions on the first side of each operator, and respectively configuring the plurality of data types as the data types of the parameters on the second side of each operator to generate a plurality of fourth expressions.
5. The database testing method according to any one of claims 1-4, characterized in that, The determining the test result corresponding to the first database according to the plurality of execution information includes: Performing a third operation on each of the plurality of operation elements supported by the first database according to the plurality of execution information to obtain the test result; the third operation includes: determining the expression including the operation element in the plurality of expressions as the test expression corresponding to the operation element; determining the performance parameter when the first database executes the operation element according to the execution information corresponding to the test expression.
6. The database testing method according to any one of claims 1-5, characterized in that Further included are: Determine a plurality of target expressions from the plurality of expressions, and obtain second test data; The target expressions are used to represent expressions generated by target operation elements and target data types; the target operation elements are used to represent operation elements supported by the first database and the second database; The target data types are used to represent data types supported by the first database and the second database; Respectively execute the plurality of target expressions in the first database and the second database to process the second test data, and obtain a plurality of first execution information corresponding to the first database and a plurality of second execution information corresponding to the second database; Determine a comparison test result according to the plurality of first execution information and the plurality of second execution information; The comparison test result is used to represent the performance difference between the first database and the second database when executing the plurality of target expressions.
7. The database testing method according to claim 6, characterized in that The first execution information includes a first duration for the target expression to complete execution in the first database; the second execution information includes a second duration for the target expression to complete execution in the second database; The determining the comparison test result according to the plurality of first execution information and the plurality of second execution information includes: Perform a fourth operation on each target expression in the plurality of target expressions according to the plurality of first execution information and the plurality of second execution information to obtain the comparison test result; The fourth operation includes: when the first duration of the target expression is less than the second duration, increase a first comparison score corresponding to the first database by a first score, and increase a second comparison score corresponding to the second database by a preset score; the first score is used to represent the ratio between the first duration of the target expression and the second duration of the target expression; when the first duration of the target expression is greater than the second duration, increase the first comparison score corresponding to the first database by the preset score, and increase the second comparison score corresponding to the second database by a second score; the second score is used to represent the ratio between the second duration of the target expression and the first duration of the target expression.
8. The database testing method according to claim 6 or 7, characterized in that Further included are: Determine a plurality of first target expressions from the plurality of target expressions; The first target expressions are used to represent target expressions whose ratio between the first duration and the second duration is greater than a preset threshold; Determine a first element sequence according to the plurality of first target expressions, where the first element sequence includes a plurality of target operation elements arranged in descending order of the number of occurrences; The number of occurrences is used to represent the number of times a target operation element appears in the plurality of first target expressions.
9. The database testing method according to any one of claims 6-8, characterized in that, The determining a plurality of target expressions from the plurality of expressions includes: Verify the multiple expressions in the first database and the second database respectively, to obtain a first verification result corresponding to the first database, and a second verification result corresponding to the second database; the first verification result is used to characterize whether each expression in the multiple expressions is allowed to be executed in the first database; the second verification result is used to characterize whether each expression in the multiple expressions is allowed to be executed in the second database; Determine the expressions that meet the preset conditions in the multiple expressions as the multiple target expressions; the preset conditions include being allowed to be executed in the first database and being allowed to be executed in the second database.
10. A database testing device, characterized in that, Comprising: An acquisition unit, an execution unit and a processing unit; The acquisition unit is used to acquire multiple expressions and first test data; the expressions include one or more operation elements supported by the first database; the operation elements include functions or operators; The execution unit is used to execute the multiple expressions in the first database to process the first test data, and obtain multiple execution information; the multiple execution information corresponds to the multiple expressions one by one, and the execution information is used to indicate the resource consumption information when the first database executes the expression to process the first test data; The processing unit is used to determine the test result corresponding to the first database according to the multiple execution information; the test result includes the performance parameters when the first database executes each operation element.
11. The database testing device according to claim 10, characterized in that, The operation element includes the function, and the acquisition unit is specifically used for: Performing a first operation on each function in the multiple functions to obtain the multiple expressions; The first operation includes: respectively configuring the multiple data types as the data types of the input parameters of the function, generating multiple first expressions, and the multiple first expressions correspond to the multiple data types one by one; or, determining multiple second expressions corresponding to the function and multiple parameter construction statements from a preset expression set, and the multiple parameter construction statements correspond to the multiple second expressions one by one, and different parameter construction statements are used to construct input parameters of different data types, and the preset expression set is used to store the expressions and parameter construction statements corresponding to the function.
12. The database testing device according to claim 10, characterized in that The operation element includes the operator, and the acquisition unit is specifically used for: Performing a second operation on the multiple operators to obtain the multiple expressions; The second operation includes: respectively configuring the multiple data types as the data types of the parameters on the first side of each operator, and respectively configuring the multiple data types as the data types of the parameters on the second side of each operator, to generate multiple third expressions; respectively configuring the multiple third expressions on the first side of each operator, and respectively configuring the multiple data types as the data types of the parameters on the second side of each operator, to generate multiple fourth expressions.
13. The database testing device according to any one of claims 10-12, wherein The obtaining unit is further configured to determine a plurality of target expressions from the plurality of expressions, and obtain second test data; the target expressions are used to represent expressions generated by target operation elements and target data types; the target operation elements are used to represent operation elements supported by the first database and the second database; The target data types are used to represent data types supported by the first database and the second database; The execution unit is further configured to respectively execute the plurality of target expressions on the second test data in the first database and the second database, to obtain a plurality of first execution information corresponding to the first database, and a plurality of second execution information corresponding to the second database; The processing unit is further configured to determine a comparison test result according to the plurality of first execution information and the plurality of second execution information; The comparison test result is used to represent the performance difference between the first database and the second database when executing the plurality of target expressions.
14. The database testing device according to claim 13, characterized in that The first execution information includes a first duration for the target expression to complete execution in the first database; the second execution information includes a second duration for the target expression to complete execution in the second database; specifically, the processing unit is configured to: Perform a fourth operation on each target expression in the plurality of target expressions according to the plurality of first execution information and the plurality of second execution information, to obtain the comparison test result; The fourth operation includes: when the first duration of the target expression is less than the second duration, increasing a first comparison score corresponding to the first database by a first score, and increasing a second comparison score corresponding to the second database by a preset score; the first score is used to represent the ratio between the first duration and the second duration of the target expression; when the first duration of the target expression is greater than the second duration, increasing the first comparison score corresponding to the first database by the preset score, and increasing the second comparison score corresponding to the second database by a second score; the second score is used to represent the ratio between the second duration and the first duration of the target expression.
15. A computer device, characterized in that, It includes a memory and a processor, the memory is used to store a computer program, and the processor is used to call the computer program to implement the database test method according to any one of claims 1 to 9.