Database partition table management method, electronic device and computer readable storage medium
By introducing a distinction management method of default partition and non-default partition in the database partition table, the problem of unreasonable partition data volume in the existing technology is solved, and more reasonable partition management and query response efficiency are achieved.
Patent Information
- Application Number
- CN202411923123.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2044-12-25
AI Technical Summary
The existing database partition table management method can easily lead to very small or large amount of data in some partitions, resulting in unreasonable management and affecting query response efficiency.
A database partition table management method is adopted to distinguish between default partitions and non-default partitions, use the default partition to store unmatched data, and create a new partition or split a non-default partition when the data amount exceeds the threshold, so as to reasonably arrange the data amount.
It effectively improves the rationality of database partition table management, ensures that the data volume of each partition is reasonably distributed, reduces the data volume of the default partition, ensures the controllability of the number of partitions, and improves query response efficiency.
Smart Images

Figure CN119357199B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of database management, and in particular to a database partition table management method, an electronic device, and a computer-readable storage medium. Background Art
[0002] As the amount of database data continues to increase, the efficiency of database query response will become slower and slower. Therefore, partition table technology is applied. Partition table is a technology for horizontally splitting tables in the database. By setting partitions with different partition ranges, a large table can be divided into multiple small tables, thereby improving response efficiency. In the prior art, the data to be written is usually written into the partition that matches the partition range. When the data to be written does not match the existing partition range, a new partition is created for the data to be written. The above partition table management method is likely to cause some partitions to have very little or very much data, resulting in unreasonable partition table management. In view of this, how to improve the rationality of database partition table management has become an urgent problem to be solved. Summary of the invention
[0003] The main technical problem solved by the present application is to provide a database partition table management method, an electronic device and a computer-readable storage medium, which can improve the rationality of database partition table management.
[0004] To solve the above technical problems, the first aspect of the present application provides a database partition table management method, wherein the database partition table includes a default partition and a non-default partition with a partition range, the method comprising: obtaining a first data volume of the default partition; wherein, when the data to be written does not match the existing partition range, the default partition is written; in response to the first data volume exceeding a partition threshold, a new partition is created in the database partition table, part of the data in the default partition is transferred to the new partition, and the partition range of the new partition is determined; obtaining a second data volume of the non-default partition; wherein, when the data to be written matches the existing partition range, the corresponding non-default partition is written; in response to the second data volume of the non-default partition exceeding the partition threshold, the non-default partition is split into multiple sub-partitions, the data in the non-default partition is distributed to the multiple sub-partitions, and the partition range of each sub-partition is determined.
[0005] To solve the above technical problems, the second aspect of the present application provides an electronic device, which includes: a memory and a processor coupled to each other, wherein the memory stores program data, and the processor calls the program data to execute the method described in the first aspect.
[0006] In order to solve the above technical problem, the third aspect of the present application provides a computer-readable storage medium on which program data is stored. When the program data is executed by a processor, the method described in the first aspect is implemented.
[0007] In the above scheme, the default partition is used to store data to be written that does not match the existing partition range, obtain the data volume in the default partition, and obtain the first data volume of the default partition. When the first data volume exceeds the partition threshold, a new partition different from the existing non-default partition is created in the database partition table, part of the data in the default partition is transferred to the new partition, and the partition range of the new partition is determined, so that the new partition with the determined partition range is converted to a non-default partition, and the data volume in the new partition can be reasonably arranged, while reducing the data volume in the default partition. The non-default partition is used to store data to be written that matches the existing partition range, obtain the data volume in the non-default partition, and obtain the second data volume of the non-default partition. When the second data volume of the non-default partition exceeds the partition threshold, the non-default partition is split into multiple sub-partitions, thereby expanding the partition, allocating the data in the non-default partition to multiple sub-partitions, and determining the partition range of each sub-partition, so that the partition range composed of all sub-partitions is still the same as the non-default partition before the split, and the data volume in each sub-partition can be reasonably arranged, and the sub-partition with the determined partition range is converted to a new non-default partition. Therefore, the default partition can always take over the data to be written that does not match the existing partition range, and when the partition is expanded to obtain a new non-default partition, the number of partitions can be controlled, and the amount of data in each non-default partition can be reasonably arranged, effectively improving the rationality of database partition table management. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. Among them:
[0009] Figure 1 It is a flowchart of an implementation method of a database partition table management method of the present application;
[0010] Figure 2 It is a flowchart of another implementation method of the database partition table management method of the present application;
[0011] Figure 3 It is a structural schematic diagram of an embodiment of the electronic device of the present application;
[0012] Figure 4 It is a structural schematic diagram of an implementation method of a computer-readable storage medium of the present application. DETAILED DESCRIPTION
[0013] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments, and different implementation methods can be adaptively combined. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0014] The terms "system" and "network" are often used interchangeably in this article. The term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship. In addition, "many" in this article means two or more than two.
[0015] The database partition table management method provided in the present application is used to manage a database partition table, which includes a default partition and a non-default partition with a partition range, and its corresponding execution subject is a processing unit capable of calling a database.
[0016] See also Figure 1 , Figure 1 It is a flowchart of an implementation method of a database partition table management method of the present application, the method comprising:
[0017] S101: Acquire a first data volume of a default partition; wherein, when the data to be written does not match an existing partition range, write the data into the default partition.
[0018] Specifically, the default partition is used to store data to be written that does not match the existing partition range, and the data volume in the default partition is obtained to obtain the first data volume of the default partition.
[0019] It should be noted that the data to be written that does not match the existing partition range is uniformly written to the default partition. Therefore, when the data to be written does not match the existing partition range, there is no need to create a partition immediately, and it can be directly written to the default partition, thereby improving writing efficiency. The difference between the default partition and the non-default partition is that the non-default partition is set with a partition range, while the default partition is not set with a partition range.
[0020] In some implementation scenarios, the amount of data in the default partition is obtained at intervals of a preset period after each preset period, to obtain a first amount of data in the default partition.
[0021] In some implementation scenarios, after the default partition completes the writing process of the data to be written, the data volume in the default partition is obtained to obtain the first data volume of the default partition.
[0022] It can be understood that after obtaining the first data volume of the default partition, it can be determined whether the first data volume of the default partition exceeds the partition threshold.
[0023] S102: In response to the first data volume exceeding the partition threshold, a new partition is created in the database partition table, part of the data in the default partition is transferred to the new partition, and a partition range of the new partition is determined.
[0024] Specifically, when the first data volume exceeds the partition threshold, a new partition different from the existing non-default partition is created in the database partition table, part of the data in the default partition is transferred to the new partition, and the partition range of the new partition is determined, so that the new partition with the determined partition range is converted into a non-default partition, and the data volume in the new partition can be reasonably arranged, while the data volume in the default partition is reduced.
[0025] It should be noted that the data to be written carries partition information, and the partition information can be used to determine the partition range of the data matching. The partition information can be obtained based on time, based on data type, or based on other attributes that can be used to classify data. This application does not impose specific restrictions on this.
[0026] In some implementation scenarios, the first data volume corresponds to at least part of the data in the default partition. When the first data volume exceeds the partition threshold, a new partition is created in the database partition table, and the data in the default partition that is less than the partition threshold is transferred to the new partition. Based on the partition information corresponding to the data transferred to the new partition, the partition range of the new partition is determined, and then the first data volume corresponding to the remaining data in the default partition is obtained again until the data volume corresponding to the remaining data in the default partition is less than the partition threshold.
[0027] In some implementation scenarios, the first data volume corresponds to all data in the default partition. When the first data volume exceeds the partition threshold, the number of new partitions to be created is determined based on the first data volume and the partition threshold, and new partitions matching the number to be created are created in the database partition table. Based on the partition information corresponding to the data in the default partition, part of the data in the default partition is transferred to the corresponding new partition so that the data volume corresponding to the remaining data in the default partition is less than the partition threshold, and the partition range of each new partition is determined based on the partition information corresponding to the data transferred to the new partition.
[0028] For the sake of convenience, this application takes the scenario where the partition range is divided according to time and the partition information is obtained based on time as an example to specifically describe the solution of this application. That is to say, the data to be written matches the data collection time as the partition information, and the time interval is used as the partition range in the non-default partition. When the collection time is within the time interval of any non-default partition, the data to be written is written to the corresponding non-default partition. When the collection time does not match all existing time intervals, it is written to the default partition, and the corresponding collection time is recorded in the default partition.
[0029] Optionally, the partition range corresponds to a minimum partition range, and the amount of sub-range data within the minimum partition range can be counted according to the minimum partition range in both the default partition and the non-default partition. In different scenarios, the minimum partition range can be set based on the average of the amount of data in the scenario, for example, the minimum partition range is set to one day, two days, or one week, etc., and this application does not impose specific restrictions on this.
[0030] S103: Acquire a second data volume of a non-default partition; wherein, when the data to be written matches an existing partition range, write into the corresponding non-default partition.
[0031] Specifically, the non-default partition is used to store data to be written that matches an existing partition range, and the data volume in the non-default partition is obtained to obtain the second data volume of the non-default partition.
[0032] It should be noted that the data to be written that matches the existing partition range is written into the corresponding non-default partition according to the partition range. The database partition table usually includes multiple non-default partitions. Therefore, the second data volume of each non-default partition needs to be obtained separately.
[0033] In some implementation scenarios, the amount of data in each non-default partition is obtained in turn after each preset period at intervals to obtain a second amount of data in the non-default partition.
[0034] In some implementation scenarios, when any non-default partition completes the writing process of the data to be written, the data volume in the corresponding non-default partition is obtained to obtain the second data volume of the non-default partition.
[0035] It can be understood that after obtaining the second data volume of the non-default partition, it can be determined whether the second data volume of the non-default partition exceeds the partition threshold.
[0036] S104: In response to the second data volume of the non-default partition exceeding the partition threshold, split the non-default partition into multiple sub-partitions, distribute the data in the non-default partition to the multiple sub-partitions, and determine the partition range of each sub-partition.
[0037] Specifically, when the second data volume of the non-default partition exceeds the partition threshold, the non-default partition is split into multiple sub-partitions to expand the partition capacity, the data in the non-default partition is distributed to multiple sub-partitions, and the partition range of each sub-partition is determined, so that the partition range composed of all sub-partitions is still the same as the non-default partition before the split, and the data volume in each sub-partition can be reasonably arranged, and the sub-partition with the determined partition range is converted into a new non-default partition.
[0038] In some implementation scenarios, when the second data volume of a non-default partition exceeds a partition threshold, the non-default partition is split into two sub-partitions, data in the non-default partition that is less than the partition threshold is transferred to one of the sub-partitions, and the remaining data is retained in the other sub-partition. Based on the partition information corresponding to the data transferred to the sub-partition, the partition range of the sub-partition is determined, and then the other sub-partition is used as a non-default partition, and the second data volume corresponding to the remaining data in the non-default partition is obtained again, until the data volume corresponding to the remaining data in the non-default partition is less than the partition threshold.
[0039] In some implementation scenarios, when the second data volume of a non-default partition exceeds a partition threshold, the number of sub-partitions to be split is determined based on the second data volume and the partition threshold, and the non-default partition is split into multiple sub-partitions that match the number of splits; based on partition information corresponding to the data in the non-default partition, all data in the non-default partition is allocated to corresponding sub-partitions so that the data volume corresponding to the data in each sub-partition is less than the partition threshold; and based on the partition information corresponding to the data in the sub-partition, the partition range of each sub-partition is determined.
[0040] It should be noted that the new partition after the partition range is determined and the sub-partition after the partition range is determined correspond to non-default partitions. The default partition and the non-default partition correspond to a preset number of computing nodes, and the partition threshold is related to the preset number and the data volume threshold of the computing node.
[0041] Specifically, when a new partition determines the corresponding partition range, it can be marked as a non-default partition. When a sub-partition determines the corresponding partition range, it can be marked as a non-default partition. Among them, both the default partition and the non-default partition correspond to a preset number of computing nodes, and each computing node corresponds to a data volume threshold. The partition threshold is determined by the product of the preset number and the data volume threshold. Therefore, each partition is set to the computing node cluster mode, considering the scale of the cluster, to avoid the situation where the environment of a single computing node is the same as the partitioning strategy of the cluster, and better query performance cannot be obtained.
[0042] It is understandable that since the expanded partition corresponds to the same number of computing nodes as the original partition, when a new partition is created or a sub-partition is obtained by splitting, a corresponding number of computing nodes will be added to the database partition table based on the number of expanded partitions.
[0043] In the above scheme, the default partition is used to store data to be written that does not match the existing partition range, obtain the data volume in the default partition, and obtain the first data volume of the default partition. When the first data volume exceeds the partition threshold, a new partition different from the existing non-default partition is created in the database partition table, part of the data in the default partition is transferred to the new partition, and the partition range of the new partition is determined, so that the new partition with the determined partition range is converted to a non-default partition, and the data volume in the new partition can be reasonably arranged, while reducing the data volume in the default partition. The non-default partition is used to store data to be written that matches the existing partition range, obtain the data volume in the non-default partition, and obtain the second data volume of the non-default partition. When the second data volume of the non-default partition exceeds the partition threshold, the non-default partition is split into multiple sub-partitions, thereby expanding the partition, allocating the data in the non-default partition to multiple sub-partitions, and determining the partition range of each sub-partition, so that the partition range composed of all sub-partitions is still the same as the non-default partition before the split, and the data volume in each sub-partition can be reasonably arranged, and the sub-partition with the determined partition range is converted to a new non-default partition. Therefore, the default partition can always take over the data to be written that does not match the existing partition range, and when the partition is expanded to obtain a new non-default partition, the number of partitions can be controlled, and the amount of data in each non-default partition can be reasonably arranged, effectively improving the rationality of database partition table management.
[0044] See also Figure 2 , Figure 2 1 is a flow chart of another implementation method of the database partition table management method of the present application, the method comprising:
[0045] S201: In a default partition, the amount of sub-range data within the minimum partition range is obtained in sequence according to the arrangement order of the minimum partition range.
[0046] Specifically, in the default partition, with the minimum partition range as an interval, according to the arrangement order of the minimum partition range, the sub-range data volume corresponding to the data in each minimum partition range is obtained in sequence.
[0047] For ease of explanation, taking the minimum partition range of one day as an example, determine the earliest current time in the default partition, obtain the minimum partition range with the highest arrangement order, and start from the first day, obtain the corresponding sub-range data volume for each day in turn.
[0048] S202: Obtain a first data volume of the default partition based on a sub-range data volume within at least a portion of a minimum partition range in the default partition.
[0049] Specifically, according to the arrangement order of the minimum partition range in the default partition, each time the sub-range data volume corresponding to a minimum partition range is obtained, the total amount of the sub-range data volume obtained can be counted as the first data volume continuously updated by the default partition, and it can be determined whether the total amount of the sub-range data volume obtained exceeds the partition threshold, so as to facilitate the determination of the minimum partition range at which the first data volume exceeds the partition threshold.
[0050] For ease of explanation, take the minimum partition range as one day and the minimum partition range as an example. When the sum of the sub-range data volume of N days does not exceed the partition threshold, the sub-range data volume of N+1 days is further obtained. When the sum of the sub-range data volume of N days exceeds the partition threshold, proceed to the subsequent steps.
[0051] S203: In response to the first data volume exceeding the partition threshold, a new partition is created in the database partition table, part of the data in the default partition is transferred to the new partition, and a partition range of the new partition is determined.
[0052] Specifically, when the first data volume exceeds the partition threshold, a new partition different from the existing non-default partition is created in the database partition table, part of the data in the default partition is transferred to the new partition, and the partition range of the new partition is determined, so that the new partition with the determined partition range is converted into a non-default partition, and the data volume in the new partition can be reasonably arranged, while the data volume in the default partition is reduced.
[0053] In some implementation scenarios, in response to the sum of the sub-range data amounts within at least part of the minimum partition range in the default partition exceeding the partition threshold, a new partition is created in the database partition table; based on the arrangement order of the minimum partition ranges, the data within all the minimum partition ranges before exceeding the partition threshold is transferred to the new partition; and based on the minimum partition range that has been transferred to the new partition, the partition range of the new partition is determined.
[0054] Specifically, when the sum of the acquired sub-range data amounts exceeds the partition threshold, a new partition is created in the database partition table, and the data within all the minimum partition ranges before exceeding the partition threshold are transferred to the new partition in the order of arrangement of the minimum partition ranges, thereby ensuring that the amount of data transferred to the new partition does not exceed the partition threshold, and ensuring that the data transferred to the new partition usually has a certain amount of data.
[0055] Furthermore, since the data is transferred in units of the minimum partition range, the partition range of the new partition can be efficiently determined based on the minimum partition range that has been transferred to the new partition, thereby improving the efficiency of transferring data in the default partition and the rationality of the data volume in the new partition.
[0056] For the sake of convenience, take the minimum partition range as one day. When the sum of the data volume of the sub-range of N days exceeds the partition threshold, when the sum of the data volume in the time range from the minimum day to N days exceeds the partition threshold, the time range of [minimum day, minimum day + N days) is used as the partition range of the new partition. The time range of this partition is closed and wrapped, such as [2023-10-01, 2023-10-02), which represents the partition on October 1, and [2023-10-01, 2023-10-03) represents the partition on October 1 and October 2.
[0057] It can be understood that after determining the partition range of the new partition based on the minimum partition range that has been transferred to the new partition, it also includes: obtaining the updated default partition, returning to the default partition, and obtaining the sub-range data volume within the minimum partition range in sequence according to the arrangement order of the minimum partition range.
[0058] Specifically, after the default partition transfers part of the data to the new partition, the default partition is updated and returns to the step of obtaining the sub-range data volume within the minimum partition range in the default partition in the order of arrangement of the minimum partition range, so as to re-judge whether the remaining data in the default partition exceeds the partition threshold, ensure that the data in the default partition is lower than the partition threshold, so that the new partition can be controllably expanded in the data table partition table according to the data volume of the default partition and ensure the rationality of the data volume in the new partition.
[0059] S204: Obtain the second data volume of each non-default partition to be analyzed in sequence according to the partition range arrangement order of all non-default partitions to be analyzed.
[0060] Specifically, in the current round, the non-default partitions whose second data volume has not been determined are marked as non-default partitions to be analyzed, and the arrangement order of all non-default partitions to be analyzed is determined according to the order that matches the partition range, and the second data volume of each non-default partition to be analyzed is obtained in turn according to the arrangement order, so as to timely determine whether the second data volume of each non-default partition exceeds the partition threshold.
[0061] It can be understood that when the second data volume of any non-default partition exceeds the partition threshold, the subsequent steps can be entered.
[0062] S205: The non-default partition whose second data volume is greater than the partition threshold and whose partition range is greater than the minimum partition range is used as the non-default partition to be split.
[0063] Specifically, when a non-default partition whose second data volume is greater than the partition threshold is obtained, it is determined whether the partition range of the corresponding non-default partition is greater than the minimum partition range. If so, the non-default partition whose second data volume is greater than the partition threshold and whose partition range is greater than the minimum partition range is used as the non-default partition to be split. Otherwise, the next non-default partition in the arrangement order is traversed, so that when the partition range of the non-default partition is already the minimum partition range, the non-default partition that cannot be split is directly ignored.
[0064] S206: In response to the second data volume of the non-default partition exceeding the partition threshold, split the non-default partition into multiple sub-partitions, distribute the data in the non-default partition to the multiple sub-partitions, and determine the partition range of each sub-partition.
[0065] Specifically, when the second data volume of the non-default partition exceeds the partition threshold, the non-default partition is split into multiple sub-partitions to expand the partition capacity, the data in the non-default partition is distributed to multiple sub-partitions, and the partition range of each sub-partition is determined, so that the partition range composed of all sub-partitions is still the same as the non-default partition before the split, and the data volume in each sub-partition can be reasonably arranged, and the sub-partition with the determined partition range is converted into a new non-default partition.
[0066] In some implementation scenarios, in response to obtaining a non-default partition to be split, in the non-default partition to be split, the sub-range data amounts within the minimum partition range are obtained in sequence according to the arrangement order of the minimum partition ranges; in response to the sum of the sub-range data amounts within at least part of the minimum partition ranges in the non-default partition to be split exceeding a partition threshold, the non-default partition to be split is split into a first sub-partition and a second sub-partition, and all data within the minimum partition ranges before exceeding the partition threshold are transferred to the first sub-partition; based on the minimum partition range that has been transferred to the first sub-partition, the partition range of the first sub-partition is determined, and based on the minimum partition range that has not been transferred to the first sub-partition, the partition range of the second sub-partition is determined.
[0067] Specifically, when a non-default partition to be split is obtained, in the non-default partition to be split, the sub-range data volume corresponding to the data in each minimum partition range is obtained in turn according to the arrangement order of the minimum partition range. Each time the sub-range data volume corresponding to a minimum partition range is obtained, the total amount of the obtained sub-range data volume can be counted to determine whether the total amount of the obtained sub-range data volume exceeds the partition threshold. This makes it easy to determine at which minimum partition range the data volume exceeds the partition threshold.
[0068] Furthermore, when the sum of the sub-range data amounts within at least part of the minimum partition range in the non-default partition to be split exceeds the partition threshold, the non-default partition to be split is split into a first sub-partition and a second sub-partition, that is, the corresponding non-default partition is split into two sub-partitions, namely, the first sub-partition and the second sub-partition.
[0069] It can be understood that, according to the arrangement order of the minimum partition range, all data within the minimum partition range before exceeding the partition threshold are transferred to the first sub-partition, thereby ensuring that the amount of data transferred to the first sub-partition does not exceed the partition threshold, and ensuring that the data transferred to the first sub-partition usually has a certain amount of data, and the second sub-partition is used to retain the remaining data.
[0070] Furthermore, since the minimum partition range is used as a unit when transferring data, the partition range of the first sub-partition can be efficiently determined based on the minimum partition range that has been transferred to the first sub-partition, thereby improving the efficiency of transferring data in the non-default partition and the rationality of the data volume in the first sub-partition. Similarly, for the minimum partition range corresponding to the data that has not been transferred to the first sub-partition, the partition range of the second sub-partition can be efficiently determined.
[0071] It can be understood that after determining the partition range of the first subpartition based on the minimum partition range that has been transferred to the first subpartition and determining the partition range of the second subpartition based on the minimum partition range that has not been transferred to the first subpartition, the method further includes: taking the second subpartition as the non-default partition to be analyzed with the frontmost arrangement order, returning to the arrangement order of the partition ranges of all non-default partitions to be analyzed, and sequentially obtaining the second data volume of each non-default partition to be analyzed.
[0072] Specifically, according to the order of traversing the non-default partitions, the second sub-partition corresponds to the non-default partition to be analyzed with the frontmost arrangement order, and the process returns to the order of the partition range arrangement of all non-default partitions to be analyzed, and the second data volume of each non-default partition to be analyzed is obtained in turn, so as to judge again whether the remaining data in the corresponding non-default partition exceeds the partition threshold. After traversing all non-default partitions, it is ensured that the data in the non-default partition is lower than the partition threshold, so that the data volume of the non-default partition in the data table partition table is kept below the partition threshold, thereby improving the efficiency of data query.
[0073] It should be noted that the new partition after determining the partition range and the sub-partition after determining the partition range are all non-default partitions. The default partition and non-default partition correspond to a preset number of computing nodes, and the partition threshold is related to the preset number and the data volume threshold of the computing node. Therefore, each partition is set to the computing node cluster mode, considering the scale of the cluster, to avoid the situation where the environment of a single computing node is the same as the partition strategy of the cluster, and better query performance cannot be obtained.
[0074] In this embodiment, according to the arrangement order of the minimum partition range in the default partition, each time the sub-range data volume corresponding to a minimum partition range is obtained, the sum of the sub-range data volumes that have been obtained can be counted as the first data volume that is continuously updated by the default partition, and it can be determined whether the sum of the sub-range data volumes that have been obtained exceeds the partition threshold, so that it is easy to determine at which minimum partition range the first data volume exceeds the partition threshold. When the sum of the sub-range data volumes that have been obtained exceeds the partition threshold, a new partition is created in the database partition table, and according to the arrangement order of the minimum partition range, all the data in the minimum partition range before exceeding the partition threshold is transferred to the new partition, so as to ensure that the data volume transferred to the new partition does not exceed the partition threshold, and to ensure that the data transferred to the new partition has a certain data volume under normal circumstances. A non-default partition whose second data volume has not been determined is marked as a non-default partition to be analyzed, and an arrangement order of all non-default partitions to be analyzed that matches the order of partition ranges is determined. The second data volume of each non-default partition to be analyzed is obtained in sequence according to the arrangement order, so that it can be timely judged whether the second data volume of each non-default partition exceeds the partition threshold. A non-default partition whose second data volume is greater than the partition threshold and whose partition range is greater than the minimum partition range is used as a non-default partition to be split. When the non-default partition to be split is obtained, in the non-default partition to be split, the sub-range data volume corresponding to the data within each minimum partition range is obtained in sequence according to the arrangement order of the minimum partition range. When the sum of the sub-range data volumes within at least part of the minimum partition ranges in the non-default partition to be split exceeds the partition threshold, the non-default partition to be split is split into a first sub-partition and a second sub-partition. According to the arrangement order of the minimum partition ranges, all the data within the minimum partition ranges before exceeding the partition threshold are transferred to the first sub-partition, so as to ensure that the data volume transferred to the first sub-partition does not exceed the partition threshold, and ensure that the data transferred to the first sub-partition usually has a certain data volume, and the second sub-partition is used to retain the remaining data. Ultimately, ensure that the data in the non-default partition is below the partition threshold, so that the data volume of the non-default partition in the data table partition table remains below the partition threshold, improving the efficiency of data query.
[0075] See also Figure 3 , Figure 3It is a structural diagram of an embodiment of an electronic device of the present application, wherein the electronic device 30 includes a memory 301 and a processor 302 coupled to each other, wherein the memory 301 stores program data (not shown), and the processor 302 calls the program data to implement the method in any of the above embodiments. For descriptions of related contents, please refer to the detailed description of the above method embodiments, which will not be repeated here.
[0076] See also Figure 4 , Figure 4 It is a structural diagram of an embodiment of a computer-readable storage medium of the present application. The computer-readable storage medium 40 stores program data 400. When the program data 400 is executed by a processor, the method in any of the above embodiments is implemented. For descriptions of related contents, please refer to the detailed description of the above method embodiments, which will not be repeated here.
[0077] It should be noted that the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present implementation scheme.
[0078] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0079] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute all or part of the steps of each implementation method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.
[0080] The above description is only an implementation method of the present application, and does not limit the protection scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly used in other related technical fields, are also included in the protection scope of the present application.
Claims
1. A database partition table management method, characterized in that: The database partition table includes a default partition without a partition range and a non-default partition with a partition range, and the method includes: Acquire a first data volume of the default partition; wherein, when the data to be written does not match the existing partition range, write the data to the default partition; In response to the first data volume exceeding a partition threshold, creating a new partition in the database partition table, transferring part of the data in the default partition to the new partition, and determining a partition range of the new partition; Acquire a second data volume of the non-default partition; wherein, when the data to be written matches the existing partition range, write the corresponding non-default partition, and the non-default partition whose second data volume exceeds the partition threshold and whose partition range is greater than the minimum partition range corresponds to the default partition to be split; In response to the second data volume of the non-default partition exceeding the partition threshold, the non-default partition is split into multiple sub-partitions, the data in the non-default partition is distributed to the multiple sub-partitions, and the partition range of each sub-partition is determined; specifically including: in response to obtaining the non-default partition to be split, in the non-default partition to be split, the sub-range data volume within the minimum partition range is sequentially obtained according to the arrangement order of the minimum partition range; in response to the sum of the sub-range data volume within at least part of the minimum partition range in the non-default partition to be split exceeding the partition threshold, the non-default partition to be split is split into a first sub-partition and a second sub-partition, and all the data within the minimum partition range before exceeding the partition threshold is transferred to the first sub-partition; based on the minimum partition range that has been transferred to the first sub-partition, the partition range of the first sub-partition is determined, and based on the minimum partition range that has not been transferred to the first sub-partition, the partition range of the second sub-partition is determined; wherein the partition range composed of all sub-partitions is still the same as the non-default partition before the split.
2. The database partition table management method according to claim 1, characterized in that: The obtaining the first data volume of the default partition includes: In the default partition, sequentially obtaining the sub-range data amount within the minimum partition range according to the arrangement order of the minimum partition range; Based on the sub-range data amount within at least part of the minimum partition range in the default partition, a first data amount of the default partition is obtained.
3. The database partition table management method according to claim 2, characterized in that: In response to the first data amount exceeding the partition threshold, creating a new partition in the database partition table, transferring part of the data in the default partition to the new partition, and determining a partition range of the new partition, including: In response to a sum of sub-range data amounts in at least part of the minimum partition range in the default partition exceeding a partition threshold, creating a new partition in the database partition table; Based on the arrangement order of the minimum partition ranges, all data within the minimum partition range before exceeding the partition threshold are transferred to the new partition; A partition range of the new partition is determined based on the smallest partition range that has been transferred to the new partition.
4. The database partition table management method according to claim 3, characterized in that: After determining the partition range of the new partition based on the minimum partition range that has been transferred to the new partition, the method further includes: The updated default partition is obtained, and the process returns to the step of obtaining the sub-range data amount within the minimum partition range in the default partition in sequence according to the arrangement order of the minimum partition range.
5. The database partition table management method according to claim 1, characterized in that: The obtaining of the second data volume of the non-default partition includes: According to the partition range arrangement order of all the non-default partitions to be analyzed, the second data volume of each non-default partition to be analyzed is obtained in sequence; The non-default partition whose second data volume exceeds the partition threshold and whose partition range is larger than the minimum partition range is used as the non-default partition to be split.
6. The database partition table management method according to claim 5, characterized in that: After determining the partition range of the first subpartition based on the smallest partition range that has been transferred to the first subpartition and determining the partition range of the second subpartition based on the smallest partition range that has not been transferred to the first subpartition, the method further includes: The second sub-partition is used as the non-default partition to be analyzed with the highest arrangement order, and the process returns to the step of sequentially acquiring the second data volume of each non-default partition to be analyzed according to the partition range arrangement order of all non-default partitions to be analyzed.
7. The database partition table management method according to any one of claims 1 to 6, characterized in that: The new partition after determining the partition range and the sub-partition after determining the partition range both correspond to non-default partitions, the default partition and the non-default partition correspond to a preset number of computing nodes, and the partition threshold is related to the preset number and the data volume threshold of the computing node.
8. An electronic device, characterized in that: include: A memory and a processor coupled to each other, wherein the memory stores program data, and the processor calls the program data to execute the method according to any one of claims 1 to 7.
9. A computer-readable storage medium having program data stored thereon, characterized in that: When the program data is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Data storage method, electronic equipment and computer readable storage medium
CN112328592A
Self-adaptive time sequence data management system and method of time sequence database
CN115422152A