Database partition adjustment method and device, equipment, storage medium and program product

By dynamically adjusting the database partition and optimizing query costs based on the database load set, the problem that the existing technology cannot adapt to dynamic load changes is solved, and the database query efficiency is improved.

CN119537480APending Publication Date: 2025-02-28CHINA TELECOM CLOUD TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411770398.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-04
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

The existing database partition restructuring strategy cannot adapt to dynamically changing loads, resulting in increased query costs and affecting the database query efficiency.

Method used

By obtaining the database access load set within the target period, the query cost is calculated. If the preset switching conditions are met, the database partition will be dynamically adjusted according to the load set to optimize the query cost.

Benefits of technology

It realizes dynamically adjusting partitions according to database load, reducing query costs, improving database query efficiency, and adapting to dynamically changing loads.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119537480A_ABST
    Figure CN119537480A_ABST
Patent Text Reader

Abstract

The invention relates to a database partition adjustment method and device, equipment, a storage medium and a program product. The method comprises the following steps: firstly, acquiring a target load set which accesses a database in a target time period and comprises a plurality of database access requests, then, according to the target load set, determining the query cost of the target load set which comprises the average query delay of the target load set, and if the query cost meets a preset switching condition, switching the database according to the query cost. And determining a dynamic database partition of the database according to the target load set, and performing partition adjustment processing on the database according to the dynamic database partition. By adopting the method, partition adjustment can be performed on the database according to the load of the database, and the query cost of the load is reduced, so that the query efficiency of the database is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of database adjustment, and in particular to a database partition adjustment method, device, equipment, storage medium and program product. Background Art

[0002] With the development of database technology, partition optimization technology has emerged. Partition optimization technology can design high-performance storage structures to reduce system load costs based on actual load conditions. Currently, commonly used partition strategies include horizontal partitioning and vertical partitioning.

[0003] In order to realize the partition reorganization of the database, many factors need to be considered, such as data distribution, changes in database request load, increase or decrease in data volume, etc. At present, the traditional partition reorganization strategy mainly adopts a timing strategy, usually an offline timing partition reorganization, which is to export all data after taking the database offline, reclaim space for the database table, and then reorder the database objects and load them into the original table. However, this partitioning method cannot adapt to dynamically changing loads. Summary of the invention

[0004] Based on this, it is necessary to provide a database partition adjustment method, device, equipment, storage medium and program product that can adjust partitions according to load in order to solve the above technical problems.

[0005] In a first aspect, the present application provides a database partition adjustment method, comprising:

[0006] Obtain a target load set for accessing a database within a target period, the target load set including multiple database access requests;

[0007] Determine the query cost of the target load set according to the target load set, where the query cost includes an average query latency of the target load set;

[0008] If the query cost meets the preset switching condition, the dynamic database partition of the database is determined according to the target load set;

[0009] Perform partition adjustment on the database based on dynamic database partitioning.

[0010] In one embodiment, determining a dynamic database partition of a database according to a target load set includes:

[0011] Determine, according to the target load set, a query range in the database for each database access request in the target load set;

[0012] Dynamic database partitions are determined based on each query range.

[0013] In one embodiment, the database partition further comprises a static database partition, and the method further comprises:

[0014] Get the partition range value of the database, which includes the partition maximum value and partition minimum value;

[0015] The database is vertically divided into a preset number of column partitions according to the database information;

[0016] According to the amount of data in the database and the partition range value, each column partition is horizontally partitioned to obtain static database partitions.

[0017] In one embodiment, obtaining a target load set for accessing a database within a target period includes:

[0018] Obtain the access frequency of all database access requests within the target period;

[0019] Database access requests with access frequencies greater than a preset frequency threshold are added to the target load set.

[0020] In one embodiment, the query cost also includes resource utilization, and the query cost of the target load set is determined according to the target load set, including:

[0021] Get the average query latency of the target load set within the target period;

[0022] Get resource utilization of dynamic database partitions;

[0023] Determine the query cost of the target load set based on the average query latency and resource utilization.

[0024] In one embodiment, before determining the query cost of the target load set according to the target load set, the following steps are included:

[0025] Obtaining a difference rate between a target load set and a historical load set, where the difference rate is used to characterize a change in access data between the target load set and the historical load set;

[0026] If the difference rate is greater than a preset difference rate threshold, a step of determining a query cost of the target load set according to the target load set is performed.

[0027] In a second aspect, the present application further provides a database partition adjustment device, comprising:

[0028] An acquisition module, used to acquire a target load set for accessing a database within a target period, the target load set including multiple database access requests;

[0029] A first determination module is used to determine the query cost of the target load set according to the target load set, where the query cost includes an average query delay of the target load set;

[0030] A second determination module is used to determine the dynamic database partition of the database according to the target load set if the query cost meets the preset switching condition;

[0031] The adjustment module is used to perform partition adjustment processing on the database according to the dynamic database partition.

[0032] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the database partition adjustment method described in any one of the first aspects is implemented.

[0033] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the database partition adjustment method described in any one of the first aspects above is implemented.

[0034] In a fifth aspect, the present application further provides a computer program product, including a computer program, which, when executed by a processor, implements the database partition adjustment method described in any one of the first aspects above.

[0035] The above-mentioned database partition adjustment method, device, equipment, storage medium and program product first obtain a target load set including multiple database access requests for accessing the database within a target period, and then determine the query cost of the target load set including the average query delay of the target load set according to the target load set. If the query cost meets the preset switching condition, the dynamic database partition of the database is determined according to the target load set, and the database is partitioned and adjusted according to the dynamic database partition. In this way, the target load set of the database is obtained, and if the query cost of the target load set meets the preset switching condition, the dynamic database partition of the database is determined according to the target load set, so that the database can be partitioned and adjusted according to the load of the database, so as to reduce the query cost of the load, thereby improving the query efficiency of the database. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0037] FIG1 is an application environment diagram of a database partition adjustment method in one embodiment;

[0038] FIG2 is a schematic diagram of a flow chart of a database partition adjustment method in one embodiment;

[0039] FIG3 is a schematic diagram of a flow chart of a database partition adjustment method in another embodiment;

[0040] FIG4 is a schematic diagram of a flow chart of a database partition adjustment method in another embodiment;

[0041] FIG5 is a schematic diagram of a query scope of a database access request in one embodiment;

[0042] FIG6 is a schematic diagram of a query scope of a database access request in one embodiment;

[0043] FIG7 is a schematic diagram of a flow chart of a database partition adjustment method in another embodiment;

[0044] FIG8 is a schematic diagram of a flow chart of a database partition adjustment method in another embodiment;

[0045] FIG9 is a schematic flow chart of a database partition adjustment method in another embodiment;

[0046] FIG10 is a schematic diagram of a module structure of a database partition adjustment method in another embodiment;

[0047] FIG11 is a structural block diagram of a database partition adjustment device in one embodiment;

[0048] FIG. 12 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0049] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0050] The database partition adjustment method provided in the embodiment of the present application can be applied to the application environment shown in Figure 1. Among them, the terminal 102 communicates with the server 104 through the network. A database is set on the server 104, which can store the data accessed by the terminal 102. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car devices, projection devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The head-mounted device can be a virtual reality (VR) device, an augmented reality (AR) device, smart glasses, etc. The server 104 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services.

[0051] In an exemplary embodiment, as shown in FIG2 , a database partition adjustment method is provided, which is described by taking the method applied to the server in FIG1 as an example, and includes the following steps 201 to 204. Among them:

[0052] Step 201: Obtain a target load set for accessing a database within a target period of time.

[0053] Wherein, the target load set includes multiple database access requests. Optionally, by real-time monitoring of information such as database access mode, data hot spots, and database load, the access frequency of database access requests is obtained, and the target load set can be determined. The target period can be a preset sampling period, and the target load set is determined by the database access requests obtained during the sampling period, wherein the target load set can be a dynamically adjusted load set, for example, it can be screened according to the access frequency of database access requests, and database access requests that meet the access frequency requirements are added to the target load set. Optionally, it can also be screened according to the access mode of the database access request.

[0054] Step 202: Determine the query cost of the target load set according to the target load set.

[0055] The query cost includes the average query latency of the target load set, which is the average time required from the issuance of a database access request in the target load set to the return of the result. Optionally, the query cost is calculated based on the current database partition situation, that is, the target load set is queried based on the current database partition, and the corresponding average query latency.

[0056] Step 203: If the query cost meets the preset switching condition, the dynamic database partition of the database is determined according to the target load set.

[0057] In order to improve the query efficiency of the database, data partitioning can be achieved through redundancy algorithms and hybrid partitioning strategies. For example, the database can be divided into a static database partition and several dynamic database partitions. That is, the database can be divided into a static database Base0 and n dynamic databases Base1...Basen, where Base0 includes all the data that the load needs to query, and can provide accurate and complete data for database access requests through traditional static heuristic rules. At the same time, the dynamic databases Base1 to Basen provide a lightweight and accurate query library for the target load set.

[0058] Optionally, the preset switching condition may be that the query cost is greater than a preset cost threshold, wherein the preset cost threshold may be set by the user based on actual conditions. When the query cost of the target load set in the current database partition is greater than the preset cost threshold, this indicates that the database access request of the target load set has changed, and the current database partition is not adapted to the dynamically changing load, that is, the current database partition needs to be optimized. Therefore, it is determined that the query cost meets the preset switching condition, and the dynamic database partition of the database can be redetermined based on the target load set.

[0059] Optionally, the preset switching condition may be that the query cost is greater than the sum of the partition adjustment cost and the expected query cost, wherein the partition adjustment cost may be determined based on resource consumption, maintenance cost, and potential data migration overhead during partition adjustment, and the expected query cost is the predicted query cost of the target load set after the database partition adjustment. By predicting the database partitions and calculating the query cost of the target load set under the predicted database partitions, if the query cost under the current database partition is greater than the sum of the partition adjustment cost and the expected query cost, that is, the current database partition needs to be optimized, the current query cost meets the preset switching condition, and the dynamic database partition of the database can be redetermined based on the target load set.

[0060] Step 204: perform partition adjustment processing on the database according to the dynamic database partition.

[0061] In database management, partition adjustment of the database requires a balance between query performance and resource consumption. If the frequency of partition adjustment is too frequent, the partition adjustment may consume too many system resources, and the partition adjustment cost is too high, affecting normal database operations. If the frequency of partition adjustment is too slow, the database query performance may be reduced due to unreasonable partitioning and inability to adapt to changes in load. Therefore, by setting preset switching conditions, a judgment can be made based on the query cost of the target load set and the preset switching conditions. When the preset switching conditions are met, the dynamic database partition of the database is determined, and the database partition is adjusted according to the dynamic database partition to meet the query requirements of the dynamically changing load.

[0062] In the above embodiment, first, a target load set including multiple database access requests for accessing the database within a target period is obtained, and then, based on the target load set, the query cost of the target load set including the average query delay of the target load set is determined, and if the query cost meets the preset switching condition, the dynamic database partition of the database is determined based on the target load set, and the partition adjustment processing of the database is performed based on the dynamic database partition. In this way, the target load set of the database is obtained, and if the query cost of the target load set meets the preset switching condition, the dynamic database partition of the database is determined based on the target load set, so that the database can be partitioned and adjusted according to the load of the database, so as to reduce the query cost of the load, thereby improving the query efficiency of the database.

[0063] In an embodiment of the present application, the process of obtaining the target load set for accessing the database within the target period in step 201 is shown in FIG3 , and includes:

[0064] Step 301: Obtain access frequencies of all database access requests within a target period.

[0065] Optionally, obtain the information of the total amount of database access requests and the access frequency of the data access requests within the target time period, for example, from the start time to the current time. Optionally, the partitioning status of the static database can be determined based on the total amount of database access requests.

[0066] Step 302: Add database access requests whose access frequency is greater than a preset frequency threshold to a target load set.

[0067] Among them, the preset frequency threshold can be set by the user according to actual needs. According to the access frequency, the access frequency is greater than the preset frequency threshold, that is, high-frequency database access requests are screened out and added to the target load set. At the same time, optionally, according to the frequency change of the database access request, when the access frequency of the database access request in the target load set decreases, the database access request with the decreased access frequency is deleted from the target load set. In other words, the target load set is dynamically adjusted to maintain the database access request with a high access frequency, so that the partitioning status of the dynamic database Base1....Basen can be determined according to the target load set.

[0068] In the above embodiment, high-frequency database access requests are added to the target load set, so that a dynamic database can be determined based on the target load set. The dynamic database can provide lightweight and accurate query capabilities to cope with rapidly changing load requirements.

[0069] In one embodiment, the steps of determining the dynamic database partition of the database according to the target load set are shown in FIG4 and include:

[0070] Step 401: Determine, according to the target load set, the query range of each database access request in the target load set in the database.

[0071] Wherein, the query range of each database access request in the target load set is determined. Optionally, for the two database access requests Sql (Structured Query Language) shown below, the query ranges of the following two query statements in the horizontal direction are shown in FIG. 5 .

[0072] Sqla:select A,B FROM R WHERE 3 <A<5 and 1<B<3

[0073] Sqlb:select A,B FROM R WHERE 2 <A<4 and 2<B<4

[0074] Step 402: Determine dynamic database partitions according to each query range.

[0075] According to the query range, that is, the sum of the range of the union consisting of the shape corresponding to Sqla and the shape corresponding to Sqlb, a dynamic database partition Base1 is determined according to the above union range. When a database access request wants to access data within the union range, it can be directly searched through the dynamic database partition Base1 without searching through the static database.

[0076] Optionally, for database access requests Sql1 to Sql5, the data included in the query range corresponding to Sql1 to Sql5 is determined in turn, as shown in Figure 6, and finally three redundant partitions are obtained, that is, dynamic database partitions such as Base2, Base3, and Base4. For subsequent database access requests, when the query range is within the above-mentioned dynamic database partition, the corresponding dynamic database partition can be directly queried.

[0077] In the above embodiment, by determining the dynamic database partition, the dynamic database partition can provide fine-grained query for the load within the query range, without the need to perform coarse-grained query on a large amount of irrelevant data in the static database, so the data query efficiency is higher.

[0078] In one embodiment, the database partitioning further includes static database partitioning. The steps of static database partitioning are shown in FIG. 7 and further include:

[0079] Step 701, obtaining the partition range value of the database.

[0080] The partition range value includes the maximum partition value and the minimum partition value. In a database, if there are too few partitions, that is, the average amount of data in each partition is too much, a large amount of invalid data will be read during the access process. If there are too many partitions, that is, the average amount of data in each partition is small, the access process can skip irrelevant partitions, but the access rate will be reduced. Therefore, the partition range of the database needs to be set according to the needs, that is, the maximum and minimum values ​​of each partition.

[0081] Step 702: vertically divide the database into a preset number of column partitions according to the database information.

[0082] As can be seen from the above, the static database Base0 provides stable static partitions, regardless of load changes, that is, the static database partitions can be determined based on database information. Optionally, the static database partitions can be determined by a hybrid partitioning method, that is, including horizontal partitions and vertical partitions. Among them, the preset number can be determined based on the column information of the database, and the database table T is vertically divided into m column partitions through vertical partitioning, where m=|T.attr|.

[0083] Step 703: perform horizontal partitioning on each column partition according to the amount of data in the database and the partition range value to obtain static database partitions.

[0084] After column partitioning, each vertical column partition is horizontally partitioned according to the amount of data in the database table, as well as the maximum and minimum values ​​of the partition, that is, the column is divided in the order of writing. Optionally, each column partition can be divided into two or evenly divided into 3-n partitions according to actual needs. Finally, each partition can be represented by the following structure.

[0085]

[0086] In the above embodiment, the static database partition of the database is obtained through the database information and the partition range. The static database contains complete data and can ensure the stability and reliability of the database system.

[0087] In one embodiment, the query cost also includes resource utilization. According to the target load set, the query cost of the target load set is determined, as shown in FIG8 , including:

[0088] Step 801, obtaining the average query latency of the target load set within the target period.

[0089] Step 802: Obtain resource utilization of the dynamic database partition.

[0090] Get the resource utilization of each dynamic database partition, such as space occupancy.

[0091] Step 803: Determine the query cost of the target load set according to the average query latency and resource utilization.

[0092] Optionally, the query cost may be a function of average query latency and resource utilization. Both average query time and resource utilization are positively correlated with the query cost. A balance between average query latency and resource utilization may be achieved by selecting a suitable adjustment strategy.

[0093] In the above embodiment, the query cost is calculated to determine whether the database partition needs to be adjusted, so that the use of data storage space can be optimized and the waste of database space can be reduced through the database partition adjustment.

[0094] In one embodiment, before determining the query cost of the target load set according to the target load set, it is necessary to monitor the change of the target load set, as shown in FIG9 , including:

[0095] Step 901, obtaining the difference rate between the target load set and the historical load set.

[0096] The difference rate is used to characterize the changes in access data between the target load set and the historical load set. The difference rate between the target load set and the historical load set is determined by real-time monitoring of the database load, including query frequency, query mode, and data access distribution.

[0097] Step 902: If the difference rate is greater than a preset difference rate threshold, a step of determining a query cost of the target load set is performed according to the target load set.

[0098] If the difference rate is greater than the preset difference rate threshold, that is, the current database load changes dynamically, the current database partition may not be able to meet the dynamically changing load. Therefore, the step of determining the query cost of the target load set based on the target load set is executed. After determining the query cost, it can be determined whether the database partition needs to be adjusted based on the query cost.

[0099] In the above embodiment, by monitoring the dynamic changes of the target load set, it is determined whether the database partition adjustment is required, so that the database partition adjustment can meet the changing requirements of the dynamic load and improve the query efficiency of the database.

[0100] In an embodiment of the present application, the database partition adjustment method can be applied to the system architecture diagram shown in Figure 10, the above database partition adjustment method is applied to the dynamic partition plug-in, and the dynamic partition plug-in is deployed in the database. The dynamic partition plug-in may include a data monitoring module, a partition algorithm module, an adaptive partition adjustment module, and a performance evaluation module.

[0101] Among them, the data monitoring module monitors the key information such as the database access mode, data hot spots and system load in real time. By continuously collecting and analyzing these data, the data monitoring module can adjust the size of the target load set and the database access requests within the target load set in real time, providing a basis for the subsequent database dynamic database partitioning strategy. In this embodiment, W{Q1...Qn} is used to represent the target load set. The historical load set includes the full query load from t0 to the current time and the access frequency and other information. The target load set is obtained by filtering the historical load set.

[0102] The partition algorithm module uses a redundant algorithm to implement dynamic database partitioning based on the information provided by the data monitoring module, which includes determining the static database partitioning and the dynamic database partitioning in the above-mentioned embodiment steps. In the initial state, all data are stored in the static database Base0, and the dynamic databases Base1 to Basen are in an idle state. As the database access mode changes, according to the changes in the above-mentioned target load set, the partition algorithm module begins to adjust the database partitioning strategy, and determines the dynamic database according to the target load set, that is, copying part of the data from Base0 to Base1 to Basen to achieve dynamic distribution of data. At the same time, the partition algorithm module also provides a hybrid redundant partitioning strategy, that is, the static database Base0 contains all the data, ensuring that under a rapidly changing load, when the data cannot be queried in the dynamic database, it can be queried from the static database Base0, and the database can still provide stable query performance.

[0103] The adaptive partition adjustment module automatically adjusts the partition strategy of the database according to the calculation results of the data monitoring module. When a significant change in the data access mode or system load is detected, it is determined whether the query cost of the target complex set meets the preset switching conditions. If the preset switching conditions are met, the database partition adjustment operation is triggered to reallocate the storage ratio of data between Base0 and Base1 to Basen to optimize query performance. Optionally, the database administrator can also manually adjust the partition strategy by modifying the configuration file or triggering a specific event to meet specific business needs. Optionally, the adaptive partition adjustment module can predict the query cost of the target load set in the future through a prediction algorithm, so as to foresee possible performance bottlenecks before the workload changes significantly, and make partition adjustments in advance to avoid emergency adjustments when performance degrades. Optionally, when adjusting the database partition, by selecting an appropriate adjustment strategy, including the number, size, and location of partitions, optimization is performed with the goal of minimizing resource consumption during the adjustment process to ensure that the new partition layout can significantly improve query performance and reduce resource consumption.

[0104] The performance evaluation module is responsible for evaluating and optimizing the performance of the dynamic partitioning plug-in. The performance evaluation module measures the effectiveness of dynamic partitioning by comparing database performance indicators before and after dynamic partitioning adjustment, such as query response time, concurrent processing capability, etc. Optionally, when it detects that database performance has degraded or there is room for optimization, the performance evaluation module can trigger the call of the adaptive partitioning adjustment module to further optimize the partitioning strategy.

[0105] In the above embodiment, dynamic partition adjustment and management of the database is implemented according to the target load set. By dividing the database into a static database and a dynamic database, the change of data access mode and the fluctuation of system load are met to improve the query performance of the data. At the same time, a hybrid redundant partitioning strategy is adopted, and partition adjustment can be performed according to demand. It has strong scalability, reduces space waste, and improves the stability and reliability of the database.

[0106] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0107] Based on the same inventive concept, the embodiment of the present application also provides a database partition adjustment device for implementing the database partition adjustment method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more database partition adjustment device embodiments provided below can refer to the limitations of the database partition adjustment method above, and will not be repeated here.

[0108] In an exemplary embodiment, as shown in FIG11 , a database partition adjustment device 1100 is provided, comprising: an acquisition module, a first determination module, a second determination module and an adjustment module, wherein:

[0109] An acquisition module, used to acquire a target load set for accessing a database within a target period, the target load set including multiple database access requests;

[0110] A first determination module is used to determine the query cost of the target load set according to the target load set, where the query cost includes an average query delay of the target load set;

[0111] A second determination module is used to determine the dynamic database partition of the database according to the target load set if the query cost meets the preset switching condition;

[0112] The adjustment module is used to perform partition adjustment processing on the database according to the dynamic database partition.

[0113] In one embodiment, the second determination module is specifically configured to determine, based on the target load set, a query range of each database access request in the target load set in the database; and determine a dynamic database partition based on each query range.

[0114] In one of the embodiments, the database partition also includes static database partition, and the device also includes a third determination module, which is used to obtain a partition range value of the database, the partition range value includes a partition maximum value and a partition minimum value; vertically divide the database into a preset number of column partitions according to database information; and horizontally partition each column partition according to the data volume of the database and the partition range value to obtain a static database partition.

[0115] In one of the embodiments, the acquisition module is specifically used to acquire the access frequency of all database access requests within the target period; and add the database access requests with access frequency greater than a preset frequency threshold to the target load set.

[0116] In one of the embodiments, the query cost also includes resource utilization, and the first determination module is specifically used to obtain the average query latency of the target load set within the target time period; obtain the resource utilization of the dynamic database partition; and determine the query cost of the target load set based on the average query latency and resource utilization.

[0117] In one of the embodiments, the device also includes an execution module for obtaining a difference rate between a target load set and a historical load set, wherein the difference rate is used to characterize changes in access data between the target load set and the historical load set; if the difference rate is greater than a preset difference rate threshold, a step of determining a query cost of the target load set based on the target load set is executed.

[0118] Each module in the above-mentioned database partition adjustment device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.

[0119] In an exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG12. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface is connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store database partition data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a database partition adjustment method is implemented.

[0120] Those skilled in the art will understand that the structure shown in FIG. 12 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.

[0121] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the following steps when executing the computer program: obtaining a target load set for accessing a database within a target period, the target load set including multiple database access requests; determining a query cost of the target load set based on the target load set, the query cost including an average query delay of the target load set; determining a dynamic database partition of the database based on the target load set if the query cost meets a preset switching condition; and performing partition adjustment processing on the database based on the dynamic database partition.

[0122] In one embodiment, when the processor executes the computer program, the following steps are also implemented: according to the target load set, determining the query range of each database access request in the target load set in the database; according to each query range, determining the dynamic database partition.

[0123] In one embodiment, the database partition also includes static database partition, and the processor further implements the following steps when executing the computer program: obtaining a partition range value of the database, the partition range value including a partition maximum value and a partition minimum value; vertically dividing the database into a preset number of column partitions according to database information; horizontally partitioning each column partition according to the data volume of the database and the partition range value to obtain a static database partition.

[0124] In one embodiment, when the processor executes the computer program, the following steps are also implemented: obtaining the access frequency of all database access requests within the target period; and adding database access requests with access frequencies greater than a preset frequency threshold to the target load set.

[0125] In one embodiment, the query cost also includes resource utilization, and the processor also implements the following steps when executing the computer program: obtaining the average query latency of the target load set within the target time period; obtaining the resource utilization of the dynamic database partition; and determining the query cost of the target load set based on the average query latency and resource utilization.

[0126] In one embodiment, when the processor executes the computer program, it also implements the following steps: obtaining the difference rate between the target load set and the historical load set, the difference rate is used to characterize the changes in access data between the target load set and the historical load set; if the difference rate is greater than a preset difference rate threshold, then executing the step of determining the query cost of the target load set based on the target load set.

[0127] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: obtaining a target load set for accessing a database within a target period of time, the target load set including multiple database access requests; determining a query cost of the target load set based on the target load set, the query cost including an average query latency of the target load set; determining a dynamic database partition of the database based on the target load set if the query cost meets a preset switching condition; and performing partition adjustment processing on the database based on the dynamic database partition.

[0128] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: according to the target load set, determining the query range of each database access request in the target load set in the database; according to each query range, determining the dynamic database partition.

[0129] In one embodiment, the database partition also includes static database partition, and the computer program, when executed by the processor, further implements the following steps: obtaining a partition range value of the database, the partition range value including a partition maximum value and a partition minimum value; vertically dividing the database into a preset number of column partitions according to database information; horizontally partitioning each column partition according to the data volume of the database and the partition range value to obtain a static database partition.

[0130] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: obtaining the access frequency of all database access requests within the target period; and adding database access requests with access frequency greater than a preset frequency threshold to the target load set.

[0131] In one embodiment, the query cost also includes resource utilization, and the computer program, when executed by the processor, also implements the following steps: obtaining the average query latency of the target load set within the target time period; obtaining the resource utilization of the dynamic database partition; and determining the query cost of the target load set based on the average query latency and resource utilization.

[0132] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: obtaining the difference rate between the target load set and the historical load set, the difference rate is used to characterize the change in access data between the target load set and the historical load set; if the difference rate is greater than a preset difference rate threshold, then executing the step of determining the query cost of the target load set based on the target load set.

[0133] In one embodiment, a computer program product is provided, including a computer program, which, when executed by a processor, implements the following steps: obtaining a target load set for accessing a database within a target period of time, the target load set including multiple database access requests; determining a query cost of the target load set based on the target load set, the query cost including an average query latency of the target load set; determining a dynamic database partition of the database based on the target load set if the query cost meets a preset switching condition; and performing partition adjustment processing on the database based on the dynamic database partition.

[0134] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: according to the target load set, determining the query range of each database access request in the target load set in the database; according to each query range, determining the dynamic database partition.

[0135] In one embodiment, the database partition also includes static database partition, and the computer program, when executed by the processor, further implements the following steps: obtaining a partition range value of the database, the partition range value including a partition maximum value and a partition minimum value; vertically dividing the database into a preset number of column partitions according to database information; horizontally partitioning each column partition according to the data volume of the database and the partition range value to obtain a static database partition.

[0136] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: obtaining the access frequency of all database access requests within the target period; and adding database access requests with access frequency greater than a preset frequency threshold to the target load set.

[0137] In one embodiment, the query cost also includes resource utilization, and the computer program, when executed by the processor, also implements the following steps: obtaining the average query latency of the target load set within the target time period; obtaining the resource utilization of the dynamic database partition; and determining the query cost of the target load set based on the average query latency and resource utilization.

[0138] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: obtaining the difference rate between the target load set and the historical load set, the difference rate is used to characterize the change in access data between the target load set and the historical load set; if the difference rate is greater than a preset difference rate threshold, then executing the step of determining the query cost of the target load set based on the target load set.

[0139] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0140] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0141] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0142] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A database partition adjustment method, characterized in that: The method comprises: Acquire a target load set for accessing a database within a target period, wherein the target load set includes multiple database access requests; Determine, according to the target load set, a query cost of the target load set, wherein the query cost includes an average query latency of the target load set; If the query cost meets the preset switching condition, determining the dynamic database partition of the database according to the target load set; The database is partitioned and adjusted according to the dynamic database partition.

2. The method according to claim 1, characterized in that: The determining the dynamic database partition of the database according to the target load set includes: Determining, according to the target load set, a query range in the database of each of the database access requests in the target load set; The dynamic database partition is determined according to each of the query ranges.

3. The method according to claim 1, characterized in that The database partition further comprises a static database partition, and the method further comprises: Obtaining a partition range value of the database, wherein the partition range value includes a partition maximum value and a partition minimum value; Vertically dividing the database into a preset number of column partitions according to database information; According to the data volume of the database and the partition range value, each of the column partitions is horizontally partitioned to obtain a static database partition.

4. The method according to claim 1, characterized in that The step of obtaining a target load set for accessing a database within a target period includes: Obtaining access frequencies of all database access requests within the target time period; The database access requests whose access frequency is greater than a preset frequency threshold are added to the target load set.

5. The method according to claim 1, characterized in that: The query cost also includes resource utilization, and determining the query cost of the target load set according to the target load set includes: Obtaining the average query latency of the target load set within the target time period; Obtaining resource utilization of the dynamic database partition; The query cost of the target load set is determined according to the average query latency and the resource utilization.

6. The method according to claim 1, characterized in that Before determining the query cost of the target load set according to the target load set, the method includes: Obtaining a difference rate between the target load set and the historical load set, where the difference rate is used to characterize a change in access data between the target load set and the historical load set; If the difference rate is greater than a preset difference rate threshold, a step of determining a query cost of the target load set according to the target load set is performed.

7. A database partition adjustment device, characterized in that: The device comprises: An acquisition module, configured to acquire a target load set for accessing a database within a target period, wherein the target load set includes a plurality of database access requests; A first determination module, configured to determine a query cost of the target load set according to the target load set, wherein the query cost includes an average query latency of the target load set; A second determination module, configured to determine the dynamic database partition of the database according to the target load set if the query cost meets a preset switching condition; The adjustment module is used to perform partition adjustment processing on the database according to the dynamic database partition.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

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

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.