Database processing method and device, equipment, storage medium and program product
By merging database instances according to the amount of data in the RocksDB database, the problem of high resource utilization and low efficiency of database instances after data migration or deletion is solved, and resource optimization and query writing efficiency are improved.
Patent Information
- Application Number
- CN202411778607.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-05
- Publication Date
- 2025-03-21
AI Technical Summary
In existing RocksDB databases, with data migration or deletion operations, the amount of data in some database instances decreases, resulting in a large number of database instances with less data occupying system and cluster resources, and the query and write efficiency is low.
By obtaining multiple database instances in the system, determining database instance bibliography based on the data volume of each instance, and combining the corresponding two database instances to reduce the number of database instances and reduce resource usage.
The number of database instances in the system is reduced through merge processing, resource occupancy is reduced, and data query and write efficiency is improved.
Smart Images

Figure CN119669293A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of storage technology, and in particular to a database processing method, device, equipment, storage medium and program product. Background Art
[0002] RocksDB is a high-performance embedded key-value database that supports high-throughput and low-latency read and write operations by adopting the LSM-tree (Log-Structured Merge Tree) structure. It is currently widely used in data storage, databases, message queues and other fields.
[0003] In the prior art, each RocksDB database instance is responsible for storing data in a key range, and the key ranges of different database instances do not overlap. However, with operations such as data migration or data deletion in the database, the amount of data in some RocksDB database instances decreases. At this time, a large number of database instances with less data occupy system and cluster resources, and the efficiency of data query and writing is low. Summary of the invention
[0004] Based on this, it is necessary to provide a database processing method, device, equipment, storage medium and program product that can improve database processing efficiency in response to the above technical problems.
[0005] In a first aspect, the present application provides a database processing method, comprising: obtaining multiple database instances in a system; determining at least one database instance tuple based on the amount of data in each database instance, the database instance tuple corresponding to two database instances; and merging the two database instances corresponding to each database instance tuple.
[0006] In one embodiment, determining at least one database instance tuple according to the data volume of each database instance includes:
[0007] Determine at least one first database instance from the multiple database instances according to the data volume of each database instance, where the data volume of the first database instance is less than a preset data volume threshold;
[0008] For each first database instance, a second database instance matching the first database instance is determined from a plurality of database instances, and a database instance tuple is determined based on the first database instance and the second database instance.
[0009] In one embodiment, determining a second database instance matching the first database instance from a plurality of database instances includes:
[0010] Sorting the multiple database instances according to a preset sorting rule to obtain a first sorting list;
[0011] If the first database instance is not the first or the last in the first sorted list, two database instances adjacent to the first database instance are determined in the first sorted list, and a second database instance is determined from the two adjacent database instances according to the data amounts of the two adjacent database instances;
[0012] If the first database instance is the first and last in the first sorted list, the database instance adjacent to the first database instance in the first sorted list is used as the second database instance.
[0013] In one embodiment, multiple database instances are sorted according to a preset sorting rule to obtain a first sorting list, including:
[0014] The multiple database instances are sorted in lexicographic order according to the range of the keys in each database instance to obtain a first sorted list.
[0015] In one embodiment, merging two database instances corresponding to each database instance tuple includes:
[0016] Determine the source database instance and the destination database instance according to the two database instances corresponding to the target database instance binary, the data volume of the destination database instance is greater than the data volume of the source database instance, and the target database instance binary is any one of the database instance binary;
[0017] Merge the files from the source database instance to the destination database instance.
[0018] In one embodiment, merging files in a source database instance into a target database instance includes:
[0019] Hard link the files of each level in the source database instance to the corresponding level in the destination database instance.
[0020] In a second aspect, the present application further provides a database processing device, the device comprising:
[0021] An acquisition module is used to acquire multiple database instances in the system;
[0022] A determination module, used to determine at least one database instance tuple according to the data volume of each database instance, where the database instance tuple corresponds to two database instances;
[0023] The merging module is used to merge the two database instances corresponding to each database instance binary.
[0024] In a third aspect, the present application further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the database processing method described in any one of the first aspects is implemented.
[0025] 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 processing method described in any one of the first aspects above is implemented.
[0026] 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 processing method described in any one of the first aspects above.
[0027] The above-mentioned database processing method, device, equipment, storage medium and program product first obtain multiple database instances in the system, then determine at least one database instance tuple corresponding to two database instances based on the data volume of each database instance obtained, and finally merge the two database instances corresponding to each database instance tuple. In this way, based on the data volume of multiple database instances, the database instance tuple that needs to be merged is determined, and after the merge process, the number of database instances in the system can be reduced, thereby reducing the resource occupancy rate of the system and improving the efficiency of data query and writing. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] 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.
[0029] Figure 1 A schematic diagram of a flow chart of a database processing method in one embodiment;
[0030] Figure 2 is a flowchart of a database processing method in another embodiment;
[0031] Figure 3 A schematic diagram of a flow chart of a step of determining a second database instance in an embodiment;
[0032] Figure 4 A schematic diagram of a process of merging database instances in one embodiment;
[0033] Figure 5 A schematic diagram of a database instance merging step in an embodiment;
[0034] Figure 6 is a flowchart of a database processing method in another embodiment;
[0035] Figure 7 is a structural block diagram of a database processing device in one embodiment;
[0036] Figure 8 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0037] 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.
[0038] In an exemplary embodiment, Figure 1 As shown, a database processing method is provided, and the method is applied to a server as an example for explanation. It can be understood that the method can also be applied to a terminal, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server, and includes the following steps:
[0039] Step 101, obtaining multiple database instances in the system.
[0040] Currently, in RocksDB, in order to avoid problems such as degraded read and write performance, write amplification, and space amplification caused by excessive data volume in database instances, database instances with large data volumes are usually split, for example, a database instance with large data volumes is split into multiple database instances with small data volumes, in order to alleviate the availability problem of database instances. However, with operations such as data migration or data deletion, the amount of data in some database instances will decrease, and even due to database deletion scenarios, all data in some database instances will be cleared, forming idle nodes, and a large number of database instances will compete for CPU time slices, increase system overhead, and reduce system performance. At the same time, too many database instances will consume system memory resources, and data query and write efficiency will be reduced.
[0041] Therefore, in order to reduce unnecessary resource overhead, database processing can be performed on database instances in the system regularly. First, it is necessary to obtain multiple database instances currently existing in the system, including the identification information, hierarchical structure, and database files of the database instances.
[0042] Step 102: Determine at least one database instance tuple according to the data volume of each database instance.
[0043] Among them, the database instance tuple corresponds to two database instances, and the database instance tuple is a combination of database instances that need to be merged. The data volume of each database instance is used to characterize the amount of data of each database instance. According to the hierarchical structure of the multiple database instances and the database files obtained above, the data volume of each database instance can be determined. According to the data volume of each database instance, at least one group of database instances that need to be merged can be determined, for example, database instances with smaller data volumes can be combined in pairs for merging.
[0044] Step 103: merge the two database instances corresponding to each database instance tuple.
[0045] Optionally, the merge process can be to copy the data in one database instance in the database instance tuple to another database instance. Through the merge process, two database instances can be merged into one database instance, and the merged database instance contains all the data in the original two database instances. This reduces the number of database instances and reduces unnecessary resource overhead in the system.
[0046] In the above embodiment, first, multiple database instances in the system are obtained, then, based on the amount of data of each database instance obtained, at least one database instance tuple corresponding to two database instances is determined, and finally, the two database instances corresponding to each database instance tuple are merged. In this way, based on the amount of data of multiple database instances, the database instance tuple that needs to be merged is determined, and after the merge process, the number of database instances in the system can be reduced, thereby reducing the resource occupancy rate of the system and improving the efficiency of data query and writing.
[0047] In one embodiment, the above step 102 is as follows Figure 2 As shown, it may include:
[0048] Step 201 : determining at least one first database instance from a plurality of database instances according to the data volume of each database instance.
[0049] Among them, the data volume of the first database instance is less than the preset data volume threshold. First, it is necessary to calculate the data volume of each database instance. Optionally, the target database instance is taken as an example for explanation, and the target database instance is any one of multiple database instances. The number of levels of the target database instance is obtained according to the hierarchical structure of the target database instance, and then the data volume of each level in the target database instance is calculated. Finally, the sum of the data volume of each level in the target database instance is used as the data volume of the target database instance. The data volume of all database instances is obtained by calculating the data volume of multiple database instances respectively, and then screening them, and the database instance with a data volume less than the preset data volume threshold is used as the first database instance, that is, the database instance that needs to be merged.
[0050] Step 202: for each first database instance, determine a second database instance matching the first database instance from a plurality of database instances, and determine a database instance tuple according to the first database instance and the second database instance.
[0051] Optionally, for each first database instance, a second database instance to be merged with the first database instance is determined from the multiple database instances obtained, and then the first database instance and the second database instance are taken as a database instance tuple. Database instances can be stored via key-value pairs, where each data item contains two parts: a key and a value. A key is a unique identifier or index used to uniquely identify and quickly retrieve a value, while a value is the data content associated with the key. Optionally, the second database instance can be a database instance that includes a key that is close to the key stored in the first database instance, or the second database instance can be a database instance whose data volume is within a preset range as compared to the data volume of the first database instance, thereby avoiding the data volume of the merged database instance being too large or too small.
[0052] In the above embodiment, a first database instance is determined based on the data volume of each database instance, and then a second database instance matching the first database instance is determined to form a database instance tuple. By screening out the first database instance with a smaller data volume among multiple database instances, database merging processing is facilitated.
[0053] In an embodiment of the present application, the step of determining a second database instance matching the first database instance from multiple database instances is as follows: Figure 3 As shown, it may include:
[0054] Step 301, sorting multiple database instances according to a preset sorting rule to obtain a first sorting list.
[0055] Optionally, the preset sorting rule may be a sorting rule set by a user, and after sorting the acquired multiple database instances according to the preset sorting rule, a first sorting list is obtained. Optionally, the multiple database instances may be sorted according to the amount of data.
[0056] Optionally, the multiple database instances may be sorted in lexicographic order according to the range of the keys in each database instance to obtain a first sorted list. For example, the first sorted list may be obtained by sorting the keys in each database instance in lexicographic order from small to large according to the range of the keys in each database instance, or by sorting the keys from large to small.
[0057] Step 302: If the first database instance is not the first or the last in the first sorted list, two database instances adjacent to the first database instance are determined in the first sorted list, and a second database instance is determined from the two adjacent database instances based on the data volume of the two adjacent database instances.
[0058] Optionally, if the first database instance is a database instance in the middle position of the first sorted list, that is, there is a database instance on each side of the first database instance, compare the data volume of the two adjacent database instances on the left and right sides of the first database instance. In order to avoid excessive data volume of the database instance after the merger, the database instance with smaller data volume in the two adjacent database instances can be selected as the second database instance for merging with the first database instance.
[0059] Step 303: If the first database instance is the first and last in the first sorted list, the database instance adjacent to the first database instance in the first sorted list is used as the second database instance.
[0060] If the first database instance is the first in the first sorted list, the database instance after the first database instance in the first sorted list, that is, the second database instance in the first sorted list, is used as the second database instance. If the first database instance is the last in the first sorted list, the database instance before the first database instance in the first sorted list, that is, the second to last database instance in the first sorted list, is used as the second database instance.
[0061] In the above embodiment, a second database instance matching the first database instance is determined based on a first sorted list. The first sorted list may be sorted from small to large according to the range of keys stored in the database instance in lexicographic order. Therefore, the keys in the second database instance may be adjacent to the keys in the first database instance, which facilitates quick search and writing.
[0062] In one embodiment of the present application, an example is given to illustrate the implementation method of determining the database instance tuple to be merged, and the steps may include:
[0063] First, multiple database instances in the cluster are obtained and sorted to obtain a first sorted list.
[0064] 1) Count the number of RocksDB database instances in the cluster and record it as DBCount. Then sort the key ranges stored in the database instances in the cluster from small to large in lexicographic order. The sorted database instance list, i.e. the first sorted list, is recorded as OrderedDBArray.
[0065] 2) Initialize the variable CurDB to 0, initialize the array SizeArray, initialize the set SelectSet, and initialize the set MergeSet.
[0066] 3) Perform a Flush operation on the CurDB database instance in OrderedDBArray to persist the data in the memory table.
[0067] Calculate the data size of each database instance in the first sorted list.
[0068] 4) Get the total level TotalLevel of the CurDB database instance in OrderedDBArray.
[0069] 5) Initialize the variable Size to 0 and the variable CurLevel to 0.
[0070] 6) Accumulate the file sizes of all SSTables (Sorted String Tables) in the CurLevel layer of the CurDB-th database instance in OrderedDBArray, recorded as LevelSize.
[0071] 7) Size plus LevelSize.
[0072] 8) Determine whether CurLevel is equal to TotalLevel.
[0073] 9) If not equal, add 1 to CurLevel and jump to step 6. If equal, jump to step 10.
[0074] 10) Change the CurDB value in SizeArray to Size, and determine whether Size is less than the preset threshold T. If Size is less than T, add CurDB to SelectSet. SelectSet stores the serial number of the database instance whose data size is less than the preset threshold, that is, the serial number of the first database instance.
[0075] Then, it is determined whether the calculation of the data volume for all database instances is completed.
[0076] 11) Determine whether the value of CurDB is equal to DBCount.
[0077] 12) If not equal, add 1 to CurDB and jump to step 3. If equal, jump to step 13.
[0078] Finally, a database instance tuple is determined according to the first database instance and the first sorted list.
[0079] 13) Traverse the SelectSet, and the serial number of the first database instance traversed is recorded as i.
[0080] 14) If the value of i is 0 and DBCount is greater than 0, the tuple (i, i+1) is stored in MergeSet. This means that the two DBs with serial numbers i and i+1 in OrderedDBArray are merged.
[0081] 15) If the value of i is DBCount and DBCount is greater than 0, the tuple (i-1,i) is stored in MergeSet.
[0082] 16) If i is any other value, then determine the size of the value of the index i-1 in the SizeArray array and the value of the index i+1 in the SizeArray array. If the value of the index i-1 is smaller, then store (i-1,i) in MergeSet. If the value of the index i+1 is smaller, then store (i,i+1) in MergeSet.
[0083] 17) Jump to step 13. If the SelectSet is traversed, jump to step 18.
[0084] 18) End. The database instance tuples stored in MergeSet are the labels of the database instances that need to be merged two by two.
[0085] In one embodiment, the steps of merging the two database instances corresponding to each database instance tuple are as follows: Figure 4 As shown, including:
[0086] Step 401 : determining a source database instance and a destination database instance according to two database instances corresponding to a target database instance tuple.
[0087] The data volume of the target database instance is greater than the data volume of the source database instance, and the target database instance tuple is any one of the database instance tuples. Optionally, the data volumes of the two database instances corresponding to the target database instance tuple are compared, and the database instance with the larger data volume is used as the target database instance, and the database instance with the smaller data volume is used as the source database instance.
[0088] Step 402: merge the files in the source database instance into the target database instance.
[0089] Optionally, hard link or copy the files in the source database instance, such as all SSTable files, to the target database instance, and then modify the log file Manifest of the target database instance. The Manifest file is an important metadata log file that records the metadata of all SSTable files in the database instance and their locations at each level. Whenever a new SSTable file is generated or an existing file is deleted or merged, the database instance will update the Manifest file to ensure the consistency and integrity of the data structure.
[0090] In the above embodiment, merging database instances by hard linking or copying SSTable files can reduce the overhead of parsing SSTable file serialization and deserialization and improve the merging speed of database instances.
[0091] Optionally, in a distributed file system that supports hard links, hard link the files at each level in the source database instance to the corresponding levels in the destination database instance. Figure 5 As shown, the total number of levels in the source database instance is obtained, and the SST files of each level in the source database instance are hard-linked to the corresponding level of the target database instance. Among them, Level0 to Level3 correspond to each level, and the SSTable files of Level0 of the source database instance are copied to Level0 in the target database instance, the SSTable files of Level1 of the source database instance are copied to Level1 in the target database instance, the SSTable files of Level2 of the source database instance are copied to Level2 in the target database instance, and the SSTable files of Level3 of the source database instance are copied to Level3 in the target database instance. If Level3 does not exist in the target database instance, Level3 is added.
[0092] In the above embodiment, the SSTable files at each level in the source database instance are hard-linked to the target database instance without the need for copying, thereby further improving the speed of database merging.
[0093] In one embodiment of the present application, an example is given to illustrate the implementation method of merging the above database instance tuples, and the steps may include:
[0094] 1) Obtain the list MergeSet of database instance tuples to be merged.
[0095] 2) Start traversing the MergeSet, record the traversed target database instance tuple as MergeJob, record the first value in the target database instance tuple as MergeJob[0], and record the second value of the target database instance as MergeJob[1].
[0096] 3) Compare the values of the subscript MergeJob[0] in SizeArray and the subscript MergeJob[1] in SizeArray. If the value of the subscript MergeJob[0] is smaller, then the value of the source database instance SrcDB is MergeJob[0] and the value of the destination database instance DstDB is MergeJob[1]. If the value of the subscript MergeJob[1] is smaller, then the value of SrcDB is MergeJob[1] and the value of DstDB is MergeJob[0].
[0097] 4) Get the total number of levels of the RocksDB instance with the subscript SrcDB in OrderedDBArray, recorded as SrcTotalLevel.
[0098] 5) Initialize the variable SrcCurLevel to 0.
[0099] 6) Hard link or copy all SST files in the SrcCurLevel layer of the RocksDB instance with the OrderedDBArray index SrcDB to the directory of the RocksDB with the OrderedDBArray index DstDB and modify the Manifest to record the operation of adding new files to the SrcCurLevel layer of RocksDB.
[0100] 7) Determine whether SrcCurLevel is equal to SrcTotalLevel.
[0101] 8) If yes, jump to step 9, otherwise increase SrcCurLevel by 1 and jump to step 6.
[0102] 9) Determine whether the MergeSet has been traversed. If not, jump to step 3; otherwise, jump to step 10.
[0103] 10) Clean up SrcDB and complete the merge of database instances.
[0104] In an embodiment of the present application, a database processing method is provided, such as Figure 6 As shown, including:
[0105] Step 601, obtaining multiple database instances in the system.
[0106] Step 602: Determine at least one first database instance from multiple database instances according to the data volume of each database instance.
[0107] Step 603: sort the multiple database instances according to a preset sorting rule to obtain a first sorting list.
[0108] Step 604 : for each first database instance, determine a second database instance matching the first database instance from a plurality of database instances, and determine a database instance tuple according to the first database instance and the second database instance.
[0109] Step 605: Determine the source database instance and the destination database instance according to the two database instances corresponding to the target database instance tuple.
[0110] Step 606: hard-link the files of each level in the source database instance to the corresponding level in the target database instance.
[0111] 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.
[0112] Based on the same inventive concept, the embodiment of the present application also provides a database processing device for implementing the database processing 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 processing device embodiments provided below can refer to the limitations on the database processing method above, and will not be repeated here.
[0113] In an exemplary embodiment, Figure 7As shown, a database processing device 700 is provided, comprising: an acquisition module 701, a determination module 702 and a merging module 703, wherein:
[0114] An acquisition module 701 is used to acquire multiple database instances in the system;
[0115] A determination module 702 is used to determine at least one database instance tuple according to the data volume of each database instance, where the database instance tuple corresponds to two database instances;
[0116] The merging module 703 is used to merge the two database instances corresponding to each database instance tuple.
[0117] In one of the embodiments, the determination module 702 is specifically used to determine at least one first database instance from multiple database instances based on the data volume of each database instance, and the data volume of the first database instance is less than a preset data volume threshold; for each first database instance, determine a second database instance matching the first database instance from the multiple database instances, and determine a database instance tuple based on the first database instance and the second database instance.
[0118] In one of the embodiments, the determination module 702 is specifically used to sort multiple database instances according to a preset sorting rule to obtain a first sorted list; if the first database instance is not the first or the last in the first sorted list, two database instances adjacent to the first database instance are determined in the first sorted list, and a second database instance is determined from the two adjacent database instances based on the amount of data in the two adjacent database instances; if the first database instance is the first or the last in the first sorted list, the database instance adjacent to the first database instance in the first sorted list is used as the second database instance.
[0119] In one embodiment, the determination module 702 is specifically configured to sort the multiple database instances in lexicographic order according to the range of the keys in each database instance to obtain a first sorted list.
[0120] In one embodiment, the merge module 703 is specifically used to determine the source database instance and the destination database instance based on the two database instances corresponding to the target database instance tuple, the data volume of the destination database instance is greater than the data volume of the source database instance, and the target database instance tuple is any one of the database instance tuples; merge the files in the source database instance into the destination database instance.
[0121] In one embodiment, the merge module 703 is specifically used to hard-link files of each level in the source database instance to the corresponding level in the target database instance.
[0122] Each module in the above database processing 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.
[0123] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Figure 8 As shown. 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 through a system bus, and the communication interface is connected to the system bus through 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 instance 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 through a network connection. When the computer program is executed by the processor, a database processing method is implemented.
[0124] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the 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 those shown in the figure, or combine certain components, or have a different arrangement of components.
[0125] 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 multiple database instances in the system; determining at least one database instance tuple based on the amount of data in each database instance, wherein the database instance tuple corresponds to two database instances; and merging the two database instances corresponding to each database instance tuple.
[0126] In one embodiment, when the processor executes the computer program, the following steps are also implemented: based on the data volume of each database instance, at least one first database instance is determined from multiple database instances, and the data volume of the first database instance is less than a preset data volume threshold; for each first database instance, a second database instance matching the first database instance is determined from multiple database instances, and a database instance tuple is determined based on the first database instance and the second database instance.
[0127] In one embodiment, when the processor executes the computer program, the following steps are also implemented: sorting multiple database instances according to a preset sorting rule to obtain a first sorted list; if the first database instance is not the first or the last in the first sorted list, determining two database instances adjacent to the first database instance in the first sorted list, and determining a second database instance from the two adjacent database instances based on the amount of data in the two adjacent database instances; if the first database instance is the first or the last in the first sorted list, using the database instance adjacent to the first database instance in the first sorted list as the second database instance.
[0128] In one embodiment, when the processor executes the computer program, the following steps are further implemented: sorting the multiple database instances in lexicographic order according to the range of the keys in each database instance to obtain a first sorted list.
[0129] In one embodiment, when the processor executes the computer program, the following steps are also implemented: determining the source database instance and the destination database instance based on the two database instances corresponding to the target database instance tuple, the data volume of the destination database instance is greater than the data volume of the source database instance, and the target database instance tuple is any one of the database instance tuples; merging the files in the source database instance into the destination database instance.
[0130] In one embodiment, when the processor executes the computer program, the following steps are further implemented: hard linking files of each level in the source database instance to corresponding levels in the destination database instance.
[0131] 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 multiple database instances in the system; determining at least one database instance tuple based on the amount of data in each database instance, where the database instance tuple corresponds to two database instances; and merging the two database instances corresponding to each database instance tuple.
[0132] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented: based on the data volume of each database instance, at least one first database instance is determined from multiple database instances, and the data volume of the first database instance is less than a preset data volume threshold; for each first database instance, a second database instance matching the first database instance is determined from multiple database instances, and a database instance tuple is determined based on the first database instance and the second database instance.
[0133] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: sorting multiple database instances according to a preset sorting rule to obtain a first sorted list; if the first database instance is not the first or the last in the first sorted list, determining two database instances adjacent to the first database instance in the first sorted list, and determining a second database instance from the two adjacent database instances based on the amount of data in the two adjacent database instances; if the first database instance is the first or the last in the first sorted list, using the database instance adjacent to the first database instance in the first sorted list as the second database instance.
[0134] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: sorting the multiple database instances in lexicographic order according to the range of the keys in each database instance to obtain a first sorted list.
[0135] In one embodiment, when the processor executes the computer program, the following steps are also implemented: determining the source database instance and the destination database instance based on the two database instances corresponding to the target database instance tuple, the data volume of the destination database instance is greater than the data volume of the source database instance, and the target database instance tuple is any one of the database instance tuples; merging the files in the source database instance into the destination database instance.
[0136] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: hard linking files of each level in the source database instance to corresponding levels in the target database instance.
[0137] In one embodiment, a computer program product is provided, including a computer program, which, when executed by a processor, implements the following steps: obtaining multiple database instances in a system; determining at least one database instance tuple based on the amount of data in each database instance, wherein the database instance tuple corresponds to two database instances; and merging the two database instances corresponding to each database instance tuple.
[0138] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented: based on the data volume of each database instance, at least one first database instance is determined from multiple database instances, and the data volume of the first database instance is less than a preset data volume threshold; for each first database instance, a second database instance matching the first database instance is determined from multiple database instances, and a database instance tuple is determined based on the first database instance and the second database instance.
[0139] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: sorting multiple database instances according to a preset sorting rule to obtain a first sorted list; if the first database instance is not the first or the last in the first sorted list, determining two database instances adjacent to the first database instance in the first sorted list, and determining a second database instance from the two adjacent database instances based on the amount of data in the two adjacent database instances; if the first database instance is the first or the last in the first sorted list, using the database instance adjacent to the first database instance in the first sorted list as the second database instance.
[0140] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: sorting the multiple database instances in lexicographic order according to the range of the keys in each database instance to obtain a first sorted list.
[0141] In one embodiment, when the processor executes the computer program, the following steps are also implemented: determining the source database instance and the destination database instance based on the two database instances corresponding to the target database instance tuple, the data volume of the destination database instance is greater than the data volume of the source database instance, and the target database instance tuple is any one of the database instance tuples; merging the files in the source database instance into the destination database instance.
[0142] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: hard linking files of each level in the source database instance to corresponding levels in the target database instance.
[0143] 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.
[0144] 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.
[0145] 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.
[0146] 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 processing method, characterized in that: The method comprises: Get multiple database instances in the system; Determine at least one database instance tuple according to the data volume of each database instance, wherein the database instance tuple corresponds to two database instances; The two database instances corresponding to each of the database instance tuples are merged.
2. The method according to claim 1, characterized in that The step of determining at least one database instance tuple according to the data volume of each database instance includes: Determine at least one first database instance from the multiple database instances according to the data volume of each of the database instances, wherein the data volume of the first database instance is less than a preset data volume threshold; For each of the first database instances, a second database instance matching the first database instance is determined from the multiple database instances, and the database instance tuple is determined according to the first database instance and the second database instance.
3. The method according to claim 2, characterized in that The determining, from the multiple database instances, a second database instance matching the first database instance comprises: Sorting the multiple database instances according to a preset sorting rule to obtain a first sorting list; If the first database instance is not the first or the last in the first sorted list, two database instances adjacent to the first database instance are determined in the first sorted list, and the second database instance is determined from the two adjacent database instances according to the data amounts of the two adjacent database instances; If the first database instance is the first and last in the first sorted list, the database instance adjacent to the first database instance in the first sorted list is used as the second database instance.
4. The method according to claim 3, characterized in that The step of sorting the plurality of database instances according to a preset sorting rule to obtain a first sorting list includes: The multiple database instances are sorted in lexicographic order according to the range of the keys in each of the database instances to obtain the first sorted list.
5. The method according to claim 1, characterized in that The merging of the two database instances corresponding to each of the database instance tuples includes: Determine a source database instance and a destination database instance according to two database instances corresponding to the target database instance binary, the data volume of the destination database instance is greater than the data volume of the source database instance, and the target database instance binary is any one of the database instance binary; Merge the files in the source database instance into the target database instance.
6. The method according to claim 5, characterized in that The merging of the files in the source database instance into the target database instance includes: The files of each level in the source database instance are hard-linked to the corresponding levels in the target database instance.
7. A database processing device, characterized in that: The device comprises: An acquisition module is used to acquire multiple database instances in the system; A determination module, configured to determine at least one database instance tuple according to the data volume of each of the database instances, wherein the database instance tuple corresponds to two database instances; The merging module is used to merge the two database instances corresponding to each of the database instance tuples.
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.
Citation Information
Cited By
Database processing method and apparatus, device, storage medium and program product
WO2026118877A1