Method, system and product for dynamically adjusting JDBC connection parameters of database

Through syntax analysis and execution probability adjustment technology, JDBC connection parameters are dynamically adjusted, which solves the difficulty of performance optimization caused by static configuration of JDBC connection parameters in the existing technology, and realizes the improvement of database query performance and applicability expansion.

CN118427230BActive Publication Date: 2024-09-20JIANGSU HUAKU DATA TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410895957.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-05
Publication Date
2024-09-20
Estimated Expiration
2044-07-05

AI Technical Summary

Technical Problem

Existing technology makes it difficult to dynamically adjust JDBC connection parameters according to query statement scenarios, making performance optimization difficult. In particular, traditional static configuration methods cannot meet the high-performance needs of modern cloud computing and big data environments.

Method used

The query statement category is obtained through syntax analysis, combined with the execution probability and actual execution time of optional parameter combinations, the JDBC connection parameters are dynamically adjusted, and the optimal parameter combination is automatically selected to avoid users from manually operating the underlying JDBC connection and manufacturer-defined API.

Benefits of technology

It realizes the dynamic adjustment of optional parameters for different SQL while the JDBC URL remains unchanged, improves database query performance, reduces the frequency of optional parameter modifications as the data volume changes, and is suitable for a variety of database systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118427230B
    Figure CN118427230B
Patent Text Reader

Abstract

The present invention relates to the technical field of database JDBC connection, and discloses a method, system and product for dynamically adjusting the JDBC connection parameters of a database, wherein the method comprises: obtaining a query statement; obtaining a query statement category according to the query statement; selecting the current optional parameter combination according to all optional parameter combinations corresponding to the query statement category and the execution probability of the optional parameter combination, and using the current optional parameter combination as the JDBC connection parameter of the query statement; recording the actual execution time used to execute the query statement; and adjusting the execution probability according to the actual execution time. The present invention performs syntax analysis on SQL to obtain the query statement, and then determines whether to use a certain connection parameter according to the statistical data of the optional parameter combination, so that the user can automatically and appropriately apply the JDBC connection parameter to each query statement without adding the optional parameter item to the JDBC URL, and obtain the optimal performance solution.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of database JDBC connection, and in particular to a method, system and product for dynamically adjusting JDBC connection parameters of a database. Background Art

[0002] In the modern cloud computing and big data environment, database systems are facing unprecedented challenges, including the sharp increase in data volume, the increase in query complexity, and the high requirements for real-time performance. In this context, traditional static configuration methods can no longer meet the needs of performance optimization.

[0003] Many application services are developed using frameworks such as MyBatis and Spring Data JPA. JDBC (Java Database Connectivity) related operations are encapsulated in the framework and users generally do not call them directly. The JDBC URL (Uniform Resource Locator) is fixed in the configuration file and the same URL is used when establishing a connection. However, some optional parameters are not applicable to all situations, such as the optional parameters OPTOFC and IFX_AUTOFREE of the JDBC URL of the Gbase 8s database. Users can call the JDBC API (Application Programming Interface) to decide which SQL (Structured Query Language) to use and which optional configuration item, but there are three disadvantages. First, some APIs are customized by database vendors and are not included in the JDBC specification, which makes it difficult to migrate the database in the future. Second, the same SQL may decide whether to enable a certain parameter item as the amount of data changes, which makes it difficult for users to write logic. Third, it is quite confusing. For example, in MyBatis, if you call the JDBC interface, part of the SQL is written in XML, and the other part calls the JDBC interface by obtaining a connection through SqlSession.

[0004] Therefore, it is particularly important to develop a technology that can dynamically adjust the JDBC connection parameters of the database. Summary of the invention

[0005] The present invention aims to solve the problem that some optional parameters of JDBC URL are not applicable to all query statement scenarios, and it is difficult to select appropriate JDBC connection parameters according to the query statement scenario. To this end, the present invention provides a method, system and product for dynamically adjusting JDBC connection parameters of a database, which performs syntax analysis on SQL to obtain query statements, and then determines whether to use a certain connection parameter based on statistical data of optional parameter combinations, so that users can automatically and appropriately apply JDBC connection parameters to each query statement without adding optional parameters to the JDBC URL, and obtain the optimal performance solution.

[0006] The present invention provides a method for dynamically adjusting JDBC connection parameters of a database, and the technical scheme adopted is as follows: comprising:

[0007] Get the query statement;

[0008] Obtaining a query statement category according to the query statement;

[0009] According to all optional parameter combinations corresponding to the query statement category and the execution probability of the optional parameter combinations, select the current optional parameter combination, and use the current optional parameter combination as the JDBC connection parameter of the query statement;

[0010] Record the actual execution time used to execute the query statement;

[0011] The execution probability of the optional parameter combination is adjusted according to the actual execution time and the execution time of the optional parameter combination.

[0012] Furthermore, the process of obtaining the query statement category according to the query statement is as follows:

[0013] The parameters in the query statement are replaced with placeholders, and then blank characters are removed to obtain the query statement category.

[0014] Furthermore, the optional parameter combination corresponding to the query statement category is 0, 1 or more of the optional parameters corresponding to the query statement category.

[0015] Furthermore, each of the optional parameter combinations corresponds to an execution time and an execution probability, and the shorter the execution time, the greater the execution probability.

[0016] Furthermore, the process of adjusting the execution probability according to the actual execution time is as follows:

[0017] If the current optional parameter combination is not the optional parameter combination with the shortest execution time among all optional parameter combinations corresponding to the query statement category, comparing the actual execution time with the shortest execution time;

[0018] If the actual execution time is greater than or equal to the minimum execution time, the execution probability of the optional parameter combination is reduced; otherwise, the optional parameter combination is used as the JDBC connection parameter of the query statement for multiple consecutive times to execute the query statement;

[0019] If the actual execution times of multiple times are all less than the minimum execution time, the execution time and execution probability of all optional parameter combinations corresponding to the query statement are cleared, and the minimum value of the actual execution times of multiple times is used as the execution time of this optional parameter combination; otherwise, the execution probability of this optional parameter combination is reduced.

[0020] Further, if the optional parameter combination is the optional parameter combination with the shortest execution time among all optional parameter combinations corresponding to the query statement category, then the actual execution time is compared with the maximum execution time;

[0021] If the actual execution time is greater than the maximum execution time, the optional parameter combination is used as the JDBC connection parameter of the query statement for multiple consecutive times to execute the query statement;

[0022] If the actual execution times of multiple times are all greater than the maximum execution time, the execution times and execution probabilities of all optional parameter combinations corresponding to the query statement are cleared, and the minimum value of the actual execution times of the multiple times is used as the execution time of this optional parameter combination; otherwise, no adjustment is made.

[0023] Furthermore, the optional parameter combination of this time is the optional parameter combination with the shortest execution time among all optional parameter combinations corresponding to the query statement category, and if the actual execution time is less than or equal to the maximum execution time, the actual execution time is compared with the minimum execution time;

[0024] If the actual execution time is less than the minimum execution time, the minimum execution time is changed to the actual execution time; otherwise, no adjustment is made.

[0025] Furthermore, the multiple times is 3 times.

[0026] The present invention also provides a system for dynamically adjusting JDBC connection parameters of a database, and the technical scheme adopted is as follows: comprising a syntax analysis component, an optional parameter selection component and a data statistics component, wherein the optional parameter selection component is connected to the syntax analysis component and the data statistics component respectively,

[0027] The syntax analysis component is used to obtain a query statement and obtain a query statement category according to the query statement;

[0028] The optional parameter selection component is used to select the current optional parameter combination according to all optional parameter combinations corresponding to the query statement category and the execution probability of the optional parameter combination, and use the current optional parameter combination as the JDBC connection parameter of the query statement; record the actual execution time used to execute the query statement, and adjust the execution probability of the optional parameter combination according to the actual execution time and the execution time of the optional parameter combination;

[0029] The data statistics component is used to store query statement categories, optional parameter combinations, execution time and execution probability.

[0030] The present invention also provides a computer program product, including a computer program, which implements the above-mentioned method for dynamically adjusting JDBC connection parameters of a database when executed by a processor.

[0031] The above one or more technical solutions in the embodiments of the present invention have at least one of the following technical effects:

[0032] 1. The present invention lists all optional parameter combinations of each SQL, and automatically selects optional parameter combinations according to execution time and execution probability, without requiring users to operate the underlying JDBC connection themselves, and also avoids users from calling non-JDBC standard manufacturer-defined APIs. The implementation of the present invention is all inside the driver, and users can use it easily.

[0033] 2. The present invention adjusts the execution probability according to the actual execution time and the execution time of the optional parameter combination, dynamically adjusts the optional parameter items, and avoids the need to regularly modify the optional parameters as the business or data volume changes.

[0034] 3. The present invention can dynamically adjust optional parameters according to SQL without changing the JDBC URL, provide different optional parameters for different SQLs, and achieve better database query performance.

[0035] 4. The present invention is not only applicable to traditional relational database systems, such as MySQL, Oracle, SQL Server, etc., but also to new NoSQL database systems, such as MongoDB, Cassandra, etc., as well as time series databases and graph databases. The present invention has wide applicability and can meet diverse data storage requirements, thereby providing the possibility of performance optimization for various application scenarios.

[0036] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0038] Figure 1 It is a structural schematic diagram provided by the present invention.

[0039] Figure 2 It is a structural schematic diagram provided by the present invention.

[0040] Reference numerals:

[0041] 1. Syntax analysis component; 2. Optional parameter selection component; 3. Data statistics component. DETAILED DESCRIPTION

[0042] In order to make the purpose, technical scheme and advantages of the present invention clearer, the technical scheme of the present invention will be clearly and completely described below in conjunction with the drawings in the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present invention. The following embodiments are used to illustrate the present invention, but cannot be used to limit the scope of the present invention.

[0043] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the embodiment of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0044] Combine the following Figure 1 and Figure 2 The present invention is further described in detail, and a method, system and product for dynamically adjusting JDBC connection parameters of a database of the present invention are described:

[0045] In this embodiment, Figure 1 As shown, a method for dynamically adjusting JDBC connection parameters of a database is provided, comprising the following steps:

[0046] Step 1: Get the query statement.

[0047] Perform syntax analysis on SQL to obtain query statements. You can use regular expressions to filter out query statements, or integrate Apache Calcite to generate an abstract syntax tree to obtain query statements.

[0048] For example: query a table, table structure: create table t1(id int, addr varchar(10));

[0049] Add AUTO_SELECT_QUERY_PARAMS=1 parameter to the JDBC URL:

[0050] jdbc:gbasedbt-sqli: / / 127.16.6.6:9088 / test:AUTO_SELECT_QUERY_PARAMS=1.

[0051] The corresponding query statement is select id,addr from t1 where id=1. This step is to perform syntax analysis on SQL to obtain the query statement.

[0052] Step 2: Obtain a query statement category according to the query statement.

[0053] The query statement obtained in step 1 generally has parameters. First, the parameters in the query statement need to be replaced with placeholders, such as "?", and then blank characters are removed to obtain the query statement category.

[0054] Replace the query statement parameters in step 1 to get select id, addr from t1 where id=?; remove the blank characters to get selectid, addr from t1 where id=?. selectid, addr from t1 where id=? is the query statement category.

[0055] Step 3: According to all optional parameter combinations corresponding to the query statement category and the execution probability of the optional parameter combination, select the current optional parameter combination, and use the current optional parameter combination as the JDBC connection parameter of the query statement.

[0056] According to the optional parameters corresponding to each query statement category, multiple optional parameter combinations can be combined. The optional parameter combination corresponding to the query statement category is 0, 1 or more of the optional parameters corresponding to the query statement category. As long as the query statement category has corresponding optional parameters, multiple optional parameter combinations can be combined.

[0057] Each of the optional parameter combinations corresponds to an execution time and an execution probability. Initially, all the optional parameter combinations corresponding to the query statement category are executed once, and the execution probability is given according to the execution time of the optional parameter combination. The shorter the execution time of the optional parameter combination, the greater the execution probability. For example, the execution probability is determined according to the execution time ratio. The execution probability will be automatically adjusted according to the subsequent actual execution time. When it is necessary to select an optional parameter combination for the query statement category, one is selected from all the optional parameter combinations as the optional parameter combination for this time according to the execution probability. The greater the execution probability, the greater the probability of being selected.

[0058] The optional parameters corresponding to each query statement category may be different, and the corresponding optional parameter combinations, execution times, and execution probabilities may also be different. Some query statement categories may correspond to the same optional parameters, that is, the same optional parameter combinations, but the execution times and execution probabilities are generally different.

[0059] Assuming that the query statement category selectid,addrfromt1whereid=? corresponds to two optional parameters, OPTOFC and IFX_AUTOFREE, there are four optional parameter combinations, namely no optional parameter, optional parameter OPTOFC, optional parameter IFX_AUTOFREE, and optional parameters OPTOFC and IFX_AUTOFREE. The execution time and execution probability corresponding to the optional parameter combinations are shown in Table 1.

[0060] Table 1 Optional parameter combinations

[0061]

[0062] When selecting the optional parameter combination of selectid,addrfromt1whereid=?, the optional parameter combination of OPTOFC and IFX_AUTOFREE has a greater probability of being selected. The other three optional parameter combinations also have a smaller probability of being selected.

[0063] Step 4: Record the actual execution time used to execute the query statement.

[0064] When the query statement is executed, this optional parameter combination is called inside the JDBC driver in the form of a JDBC API, and the actual execution time of the query statement is recorded.

[0065] Step 5: Adjust the execution probability of the optional parameter combination according to the actual execution time and the execution time of the optional parameter combination.

[0066] The actual execution time is used as a feedback and compared with the execution time to adjust the execution probability of the optional parameter combination, so as to achieve the purpose of dynamically adjusting the optional parameter combination selected by the query statement category.

[0067] The process of adjusting the execution probability according to the actual execution time is:

[0068] If the current optional parameter combination is not the optional parameter combination with the shortest execution time among all optional parameter combinations corresponding to the query statement category, the actual execution time is compared with the shortest execution time.

[0069] If the actual execution time is greater than or equal to the minimum execution time, the execution probability of the optional parameter combination is reduced, so that the execution probability of the optional parameter combination that is not the minimum execution time will become lower and lower until it approaches 0. Otherwise, the optional parameter combination is used as the JDBC connection parameter of the query statement for multiple consecutive times to execute the query statement.

[0070] If the actual execution time for multiple times is less than the minimum execution time, then clear the execution time and execution probability of all optional parameter combinations corresponding to the query statement, and use the minimum value of the actual execution time as the execution time of this optional parameter combination; otherwise, reduce the execution probability of this optional parameter combination. When initially determining the execution probability of each optional parameter combination, it is inevitable that unreasonableness may occur. By executing the query statement multiple times in succession, the optional parameter combination corresponding to the minimum execution time can be effectively determined. Three times is a more reasonable number of consecutive executions.

[0071] Clearing the execution time and execution probability of all optional parameter combinations corresponding to a query statement will result in no corresponding execution time for the optional parameter combination. The optional parameter combinations without execution time can be used as the current optional parameter combination, and the query statement can be executed once to obtain the execution time, and then the execution probability of all optional parameter combinations can be determined.

[0072] Taking the optional parameter combination of selectid,addrfromt1whereid=? as an example, it can be seen from Table 1 that the minimum execution time is 70000 nanoseconds, and the optional parameter combination of OPTOFC and IFX_AUTOFREE is the optional parameter combination with the shortest execution time.

[0073] Assume that the optional parameter combination with the optional parameter OPTOFC is selected as the optional parameter combination for this time in step 3, which is not the optional parameter combination with the shortest execution time; the actual execution time recorded in step 4 is 150000 nanoseconds. If the actual execution time is greater than the shortest execution time, the execution probability of the optional parameter combination with the optional parameter OPTOFC is reduced, for example, from 5% to 2.5%.

[0074] Assume that in step 3, the optional parameter combination with the optional parameter OPTOFC is still selected as the optional parameter combination for this time, but the actual execution time recorded in step 4 is 68000 nanoseconds. If the actual execution time is less than the minimum execution time, OPTOFC is used as the JDBC connection parameter of the query statement for three consecutive times to execute the query statement and record three actual execution times. If the three actual execution times are 65000 nanoseconds, 66000 nanoseconds and 69000 nanoseconds, respectively, which are all less than the minimum execution time (70000 nanoseconds), then clear all execution times and execution probabilities in Table 1, and then use 65000 nanoseconds as the execution time of the optional parameter combination with the optional parameter OPTOFC. Then use the other three optional parameter combinations to execute the query statement once respectively to obtain the execution time, and determine the execution probability of the optional parameter combination according to the execution time of the four optional parameter combinations. The execution of these three query statements can be executed immediately after clearing the data, or when the query statement category of selectid,addrfromt1whereid=? is obtained again in the future, they can be executed in sequence.

[0075] If the optional parameter combination is the optional parameter combination with the shortest execution time among all optional parameter combinations corresponding to the query statement category, no adjustment is required. Alternatively, a method similar to the above judgment logic can be used to perform a logical judgment on the situation where the optional parameter combination is the optional parameter combination with the shortest execution time, so as to more quickly find the unreasonableness when initially determining the execution probability of each optional parameter combination. The specific process is as follows:

[0076] If the optional parameter combination is the optional parameter combination with the shortest execution time among all optional parameter combinations corresponding to the query statement category, then comparing the actual execution time with the maximum execution time;

[0077] If the actual execution time is greater than the maximum execution time, the optional parameter combination is used as the JDBC connection parameter of the query statement for multiple consecutive times to execute the query statement;

[0078] If the actual execution times of multiple times are all greater than the maximum execution time, the execution times and execution probabilities of all optional parameter combinations corresponding to the query statement are cleared, and the minimum value of the actual execution times of the multiple times is used as the execution time of this optional parameter combination; otherwise, no adjustment is made.

[0079] Take selectid,addrfromt1whereid=? as an example. Assume that the optional parameter combination of OPTOFC and IFX_AUTOFREE is selected as the optional parameter combination in step 3, which is the optional parameter combination with the shortest execution time; the actual execution time recorded in step 4 is 310000 nanoseconds.

[0080] If the actual execution time is greater than the maximum execution time (300,000 nanoseconds), then use OPTOFC and IFX_AUTOFREE as the JDBC connection parameters of the query statement for three consecutive times, execute the query statement, and record the three actual execution times. If the three actual execution times are 310,000 nanoseconds, 320,000 nanoseconds, and 320,000 nanoseconds, respectively, which are all greater than the maximum execution time, then clear all execution times and execution probabilities in Table 1, and then use 310,000 nanoseconds as the execution time of the optional parameter combination with the optional parameters OPTOFC and IFX_AUTOFREE. After the other three optional parameter combinations are executed once to obtain the execution time, the execution probability of the optional parameter combination is re-determined based on the execution time of the four optional parameter combinations.

[0081] Assuming that the optional parameter combination of OPTOFC and IFX_AUTOFREE is selected as the optional parameter combination this time in step 3, and the actual execution time recorded in step 4 is 80000 nanoseconds, no adjustment is made, and the content of Table 1 remains unchanged.

[0082] Considering that the initial determination of the execution time of each optional parameter combination may be inaccurate, further judgment logic can be added, specifically:

[0083] The optional parameter combination this time is the optional parameter combination with the shortest execution time among all optional parameter combinations corresponding to the query statement category. If the actual execution time is less than or equal to the maximum execution time, the actual execution time is compared with the minimum execution time; if the actual execution time is less than the minimum execution time, the minimum execution time is changed to the actual execution time; otherwise, no adjustment is made.

[0084] Assuming that the optional parameter combination of OPTOFC and IFX_AUTOFREE is selected as the optional parameter combination this time in step 3, and the actual execution time recorded in step 4 is 68000 nanoseconds, the execution time in Table 1 is modified from 70000 nanoseconds to 68000 nanoseconds.

[0085] The present invention adjusts the execution probability according to the actual execution time and the execution time, and can continuously reduce the execution probability of multiple optional parameter combinations whose execution time is not the least, and increase the number of times the optional parameter combination with the least execution time is selected, so that the performance of all query statements is greatly improved. Except for several fluctuations when the low-probability optional parameter combination is executed, the present invention can maintain high-performance query with the best parameter combination.

[0086] In this embodiment, Figure 2 As shown, a system for dynamically adjusting JDBC connection parameters of a database is also provided, comprising a syntax analysis component 1, an optional parameter selection component 2 and a data statistics component 3, wherein the optional parameter selection component 2 is connected to the syntax analysis component 1 and the data statistics component 3 respectively.

[0087] The syntax analysis component 1 is used to obtain a query statement and obtain a query statement category according to the query statement;

[0088] The optional parameter selection component 2 is used to select the current optional parameter combination according to all optional parameter combinations corresponding to the query statement category and the execution probability of the optional parameter combination, and use the current optional parameter combination as the JDBC connection parameter of the query statement; record the actual execution time used to execute the query statement, and adjust the execution probability of the optional parameter combination according to the actual execution time and the execution time of the optional parameter combination;

[0089] The data statistics component 3 is used to store query statement categories, optional parameter combinations, execution time and execution probability.

[0090] The working process of this system is:

[0091] The syntax analysis component 1 performs syntax analysis on SQL to obtain a query statement, replaces the parameters in the query statement with "?", and then removes blank characters to obtain the query statement category, and sends the query statement category to the optional parameter selection component 2.

[0092] After receiving the query statement category, the optional parameter selection component 2 retrieves the corresponding optional parameter combination, as well as the execution time and execution probability of the optional parameter combination from the data statistics component 3 according to the query statement category. According to the execution probabilities of all optional parameter combinations, an optional parameter combination is determined as the current optional parameter combination, and the current optional parameter combination is used as the JDBC connection parameter of the query statement. When the query statement is executed, the current optional parameter combination will be called inside the JDBC driver in the form of a JDBC API.

[0093] When the query statement is executed, the optional parameter selection component 2 records the actual execution time used to execute the query statement, and then compares the actual execution time with the corresponding execution time stored in the data statistics component 3, and selects whether to adjust the execution probability of the optional parameter combination corresponding to the query statement category and modify the stored data of the data statistics component 3 according to the comparison result. The specific process is:

[0094] If the current optional parameter combination is not the optional parameter combination with the shortest execution time among all optional parameter combinations corresponding to the query statement category, comparing the actual execution time with the shortest execution time;

[0095] If the actual execution time is greater than or equal to the minimum execution time, the execution probability of the optional parameter combination is reduced; otherwise, the optional parameter combination is used as the JDBC connection parameter of the query statement for three consecutive times to execute the query statement;

[0096] If the actual execution times of the three times are all less than the minimum execution time, the execution time and execution probability of all optional parameter combinations corresponding to the query statement are cleared, and the minimum value of the multiple actual execution times is used as the execution time of this optional parameter combination; otherwise, the execution probability of this optional parameter combination is reduced.

[0097] If the optional parameter combination is the optional parameter combination with the shortest execution time among all optional parameter combinations corresponding to the query statement category, then comparing the actual execution time with the maximum execution time;

[0098] If the actual execution time is greater than the maximum execution time, the optional parameter combination is used as the JDBC connection parameter of the query statement for three consecutive times to execute the query statement;

[0099] If the actual execution times of the three times are all greater than the maximum execution time, the execution time and execution probability of all optional parameter combinations corresponding to the query statement are cleared, and the minimum value of the multiple actual execution times is used as the execution time of this optional parameter combination; otherwise, no adjustment is made.

[0100] The optional parameter combination this time is the optional parameter combination with the shortest execution time among all optional parameter combinations corresponding to the query statement category. If the actual execution time is less than or equal to the maximum execution time, the actual execution time is compared with the minimum execution time; if the actual execution time is less than the minimum execution time, the minimum execution time is changed to the actual execution time; otherwise, no adjustment is made.

[0101] The user clearly knows the query statement category of the optimal optional parameter combination, and can manually adjust the execution probability of the optimal optional parameter combination to 100% and the execution probability of other optional parameter combinations to 0% in the data statistics component 3; or delete other optional parameter combinations.

[0102] When the syntax analysis component 1 obtains a completely new query statement category, that is, the query statement category is not stored in the data statistics component 3, all optional parameters of the query statement category can be determined first to form multiple optional parameter combinations, and then all optional parameter combinations are executed separately to obtain the execution time of all optional parameter combinations, and then the execution probability is calculated and stored in the data statistics component 3. Since the number of optional JDBC connection parameters is small, there are only a few, and the number of generated optional parameter combinations will not be too many, so the overhead required to execute this method is completely acceptable.

[0103] In this embodiment, a computer program product is also provided, including a computer program, and when the computer program is executed by a processor, the computer program implements the above-mentioned method for dynamically adjusting JDBC connection parameters of the database.

[0104] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. Dynamic adjustment method of JDBC connection parameters of database, It is characterized in that include: Get the query statement; Obtaining a query statement category according to the query statement; According to all optional parameter combinations corresponding to the query statement category and the execution probability of the optional parameter combinations, select the current optional parameter combination, and use the current optional parameter combination as the JDBC connection parameter of the query statement; Record the actual execution time used to execute the query statement; adjusting the execution probability of the optional parameter combination according to the actual execution time and the execution time of the optional parameter combination; The process of adjusting the execution probability according to the actual execution time is: If the current optional parameter combination is not the optional parameter combination with the shortest execution time among all optional parameter combinations corresponding to the query statement category, comparing the actual execution time with the shortest execution time; If the actual execution time is greater than or equal to the minimum execution time, then the execution probability of the optional parameter combination is reduced; Otherwise, the optional parameter combination is used as the JDBC connection parameter of the query statement for multiple consecutive times to execute the query statement; If the actual execution times of multiple times are all less than the minimum execution time, the execution time and execution probability of all optional parameter combinations corresponding to the query statement are cleared, and the minimum value of the actual execution times of multiple times is used as the execution time of this optional parameter combination; otherwise, the execution probability of this optional parameter combination is reduced.

2. The method for dynamically adjusting JDBC connection parameters of a database according to claim 1, It is characterized in that The process of obtaining the query statement category according to the query statement is as follows: The parameters in the query statement are replaced with placeholders, and then blank characters are removed to obtain the query statement category.

3. The method for dynamically adjusting JDBC connection parameters of a database according to claim 1, It is characterized in that The optional parameter combination corresponding to the query statement category is 0, 1 or more of the optional parameters corresponding to the query statement category.

4. The method for dynamically adjusting JDBC connection parameters of a database according to claim 1, It is characterized in that Each of the optional parameter combinations corresponds to an execution time and an execution probability.

5. The method for dynamically adjusting JDBC connection parameters of a database according to claim 1, It is characterized in that If the optional parameter combination is the optional parameter combination with the shortest execution time among all optional parameter combinations corresponding to the query statement category, then comparing the actual execution time with the maximum execution time; If the actual execution time is greater than the maximum execution time, the optional parameter combination is used as the JDBC connection parameter of the query statement for multiple consecutive times to execute the query statement; If the actual execution times of multiple times are all greater than the maximum execution time, the execution times and execution probabilities of all optional parameter combinations corresponding to the query statement are cleared, and the minimum value of the actual execution times of multiple times is used as the execution time of this optional parameter combination; Otherwise no adjustment is made.

6. The method for dynamically adjusting JDBC connection parameters of a database according to claim 5, It is characterized in that The optional parameter combination of this time is the optional parameter combination with the shortest execution time among all the optional parameter combinations corresponding to the query statement category, and if the actual execution time is less than or equal to the maximum execution time, the actual execution time is compared with the minimum execution time; If the actual execution time is less than the minimum execution time, the minimum execution time is changed to the actual execution time; Otherwise no adjustment is made.

7. The method for dynamically adjusting JDBC connection parameters of a database according to claim 1, It is characterized in that The multiple times is 3 times.

8. Dynamic adjustment system of JDBC connection parameters of database, It is characterized in that The method for dynamically adjusting the JDBC connection parameters of a database according to any one of claims 1 to 7 comprises: a syntax analysis component, an optional parameter selection component and a data statistics component, wherein the optional parameter selection component is connected to the syntax analysis component and the data statistics component respectively. The syntax analysis component is used to obtain a query statement and obtain a query statement category according to the query statement; The optional parameter selection component is used to select the current optional parameter combination according to all optional parameter combinations corresponding to the query statement category and the execution probability of the optional parameter combination, and use the current optional parameter combination as the JDBC connection parameter of the query statement; record the actual execution time used to execute the query statement, and adjust the execution probability of the optional parameter combination according to the actual execution time and the execution time of the optional parameter combination; The process of adjusting the execution probability according to the actual execution time is: If the current optional parameter combination is not the optional parameter combination with the shortest execution time among all optional parameter combinations corresponding to the query statement category, comparing the actual execution time with the shortest execution time; If the actual execution time is greater than or equal to the minimum execution time, the execution probability of the optional parameter combination is reduced; otherwise, the optional parameter combination is used as the JDBC connection parameter of the query statement for multiple consecutive times to execute the query statement; If the actual execution times of multiple times are all less than the minimum execution time, the execution time and execution probability of all optional parameter combinations corresponding to the query statement are cleared, and the minimum value of the actual execution times of multiple times is used as the execution time of this optional parameter combination; otherwise, the execution probability of this optional parameter combination is reduced; The data statistics component is used to store query statement categories, optional parameter combinations, execution time and execution probability.

9. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the method for dynamically adjusting the JDBC connection parameters of a database according to any one of claims 1 to 7 is implemented.