Database partitioning method and device, electronic equipment and storage medium

The database partitioning method efficiently locates target partitions by identifying key value positions and adjusting dynamic steps, enhancing partitioning efficiency and accuracy in high-transaction-volume environments.

CN119226400APending Publication Date: 2024-12-31PING AN TECH (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411273128.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-11
Publication Date
2024-12-31

AI Technical Summary

Technical Problem

Existing database partitioning methods are inefficient when locating target database partitions that are far from existing partitions, particularly in high-transaction-volume environments like the financial sector, as they rely on gradually accumulating or decreasing step sizes, leading to low efficiency.

Method used

A database partitioning method that identifies the position of a target partition key value relative to existing partitions, adjusts a dynamic partition step based on this position, and performs positional traversals to quickly locate the target partition, using modules to acquire and traverse key values to create efficient database partitions.

Benefits of technology

This method facilitates accurate and efficient database partitioning by enabling targeted positioning of target partitions, ensuring data integrity and reducing traversal steps, thereby improving management efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119226400A_ABST
    Figure CN119226400A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a database partitioning method and device, electronic equipment and a storage medium, and belongs to the technical field of financial science and technology and data processing. The method comprises the following steps: determining a target partition position based on a dynamic partition step length, a partition starting position, a partition ending position and a partition key value position; and according to the partition key value positions, performing position traversal on the target partition key values among the target partition positions, and creating partitions for the target partition key values according to the traversal key value positions and the target partition positions. According to the method, the target partition key value is subjected to position identification, so that the target database partition can be positioned in a targeted manner, and the database partition efficiency is improved; and according to the partition key value positions, position circulating traversal is performed on the target partition key values among the target partition positions, so that the dynamic partition step length can be adjusted according to the different partition key value positions, the interval position of the target database partition to be created can be quickly positioned, and the database partition efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the fields of financial technology and data processing technology, and in particular to a database partitioning method and device, an electronic device and a storage medium. Background Art

[0002] At present, when a target key value needs to be inserted and the corresponding database partition does not exist, the database partition is usually performed according to the location of the existing database partition by gradually accumulating or gradually decreasing. For example, in the financial field, with the increase in the transaction volume of insurance products, in order to improve the management efficiency of insurance product transaction data, multiple database partitions are usually created by transaction date or transaction tD range for management. However, when the distance between the target database partition and the existing database partition is far, this method can only locate the starting interval of the target database partition by gradually accumulating or gradually decreasing the step size, resulting in low efficiency of database partitioning. Therefore, how to improve the efficiency of database partitioning has become an urgent problem to be solved. Summary of the invention

[0003] The main purpose of the embodiments of the present application is to provide a database partitioning method and device, an electronic device and a storage medium, aiming to improve the efficiency of database partitioning.

[0004] To achieve the above object, a first aspect of an embodiment of the present application proposes a database partitioning method, the method comprising:

[0005] Get the target partition key value;

[0006] Obtaining a current database partition and obtaining a partition interval of the current database partition; wherein the partition interval includes a partition start position and a partition end position of each current database partition;

[0007] According to the partition start position and the partition end position, the target partition key value is identified to obtain the partition key value position;

[0008] Determine a target partition start position and a target partition end position based on a preset dynamic partition step, the partition start position, the partition end position and the partition key value position;

[0009] According to the partition key value position, the target partition key value is positionally traversed between the target partition start position and the target partition end position to obtain a traversed key value position;

[0010] The target partition key value is partitioned and created according to the traversal key value position, the target partition starting position and the target partition ending position to obtain a target database partition.

[0011] In some embodiments, the partition key value position is used to indicate that: the target partition key value is located before the partition start position, the target partition key value is located between the partition start position and the partition end position, and the target partition key value is located after the partition end position;

[0012] The step of identifying the position of the target partition key value according to the partition start position and the partition end position to obtain the partition key value position includes:

[0013] Performing a post-position detection on the target partition key value according to the partition termination position to obtain the post-position partition key value position;

[0014] Performing a leading position detection on the target partition key value according to the partition starting position to obtain the leading partition key value position;

[0015] The target partition key value is detected at a center position according to the partition start position and the partition end position to obtain the center partition key value position.

[0016] In some embodiments, the determining the target partition start position and the target partition end position based on the preset dynamic partition step, the partition start position, the partition end position and the partition key value position includes:

[0017] If the partition key value position is the preceding partition key value position, the preceding dynamic partition step of the dynamic partition step is obtained according to the preceding partition key value position, the preceding target partition starting position is determined according to the partition initial position and the preceding dynamic partition step, and the partition initial position is used as the preceding target partition ending position;

[0018] If the partition key value position is the centered partition key value position, the centered dynamic partition step of the dynamic partition step is obtained according to the centered partition key value position, the first centered target partition starting position is determined according to the partition ending position and the centered dynamic partition step, and the second centered target partition starting position is determined based on the partition starting position and the centered dynamic partition step, and the centered target partition ending position is determined according to the partition starting position; the second centered target partition starting position is greater than the first centered target partition starting position;

[0019] If the partition key value position is a post-partition key value position, the post-dynamic partition step of the dynamic partition step is obtained according to the post-partition key value position, the post-target partition starting position is determined based on the partition end position and the post-dynamic partition step, the post-partition step constant is obtained, and the post-target partition end position is determined based on the post-dynamic partition step and the post-partition step constant.

[0020] In some embodiments, if the partition key value position is the preceding partition key value position;

[0021] The step of performing a position loop traversal on the target partition key value between the target partition start position and the target partition end position according to the partition key value position to obtain the traversal key value position includes:

[0022] The target partition key value is positionally traversed between the starting position of the preceding target partition and the ending position of the preceding target partition to obtain the preceding traversal key value position; the preceding traversal key value position is used to indicate that the target partition key value exists between the starting position of the preceding target partition and the starting position of the preceding target partition or that the target partition key value does not exist between the starting position of the preceding target partition and the starting position of the preceding target partition;

[0023] If the preceding traversal key value position indicates that the target partition key value does not exist between the preceding target partition starting position and the preceding target partition starting position, the preceding dynamic partition step size is reduced to obtain a reduced preceding dynamic partition step size, and the preceding target partition starting position is used as an updated preceding target partition terminating position, and the preceding target partition starting position is updated according to the updated preceding target partition terminating position and the reduced preceding dynamic partition step size to obtain an updated preceding target partition starting position;

[0024] The target partition key value is positionally looped between the update preceding target partition start position and the update preceding target partition end position until the target partition key value exists between the update preceding target partition start position and the update preceding target partition end position.

[0025] In some embodiments, if the partition key value position is the center partition key value position;

[0026] The step of performing a position loop traversal on the target partition key value between the target partition start position and the target partition end position according to the partition key value position to obtain the traversal key value position includes:

[0027] The target partition key value is positionally traversed between the first centered target partition starting position, the second centered target partition starting position and the centered target partition ending position to obtain the centered traversal key value position; the centered traversal key value position is used to indicate that the target partition key value exists between the first centered target partition starting position and the second centered target partition starting position, or the target partition key value exists before the first centered target partition starting position, or the target partition key value exists between the second centered target partition starting position and the centered target partition ending position;

[0028] If the centered traversal key value position is used to indicate that the target partition key value exists before the first centered target partition starting position, the centered dynamic partition step size is increased to obtain an increased centered dynamic partition step size, and the first centered target partition starting position is updated according to the partition end position and the increased centered dynamic partition step size to obtain an updated first centered target partition starting position;

[0029] Performing a position loop traversal of the target partition key value between the updated first centered target partition starting position and the second centered target partition starting position until the target partition key value exists between the updated first centered target partition starting position and the second centered target partition starting position;

[0030] If the centered traversal key value position is used to indicate that the target partition key value exists between the second centered target partition starting position and the centered target partition ending position, the centered dynamic partition step size is reduced to obtain the reduced centered dynamic partition step size, and the second centered target partition starting position is updated according to the partition starting position and the reduced centered dynamic partition step size to obtain an updated second centered target partition starting position;

[0031] The target partition key value is positionally looped between the start position of the updated second centered target partition and the end position of the centered target partition until the target partition key value exists between the start position of the updated second centered target partition and the end position of the centered target partition.

[0032] In some embodiments, if the partition key value position is the post-partition key value position;

[0033] The step of performing a position loop traversal on the target partition key value between the target partition start position and the target partition end position according to the partition key value position to obtain the traversal key value position includes:

[0034] The target partition key value is positionally traversed between the post-target partition start position and the post-target partition end position to obtain the post-traversal key value position; the post-traversal key value position is used to indicate that the target partition key value exists between the post-target partition start position and the post-target partition end position, or the target partition key value exists before the post-target partition start position, or the target partition key value exists after the post-target partition end position;

[0035] If the post-traversal key value position is used to indicate that the target partition key value exists before the post-target partition starting position, the post-dynamic partition step size is reduced to obtain a reduced post-dynamic partition step size, and the post-target partition starting position is updated according to the partition end position and the reduced post-dynamic partition step size to obtain an updated post-target partition starting position;

[0036] Performing a position loop traversal of the target partition key value between the starting position of the post-update target partition and the ending position of the post-update target partition until the target partition key value exists between the starting position of the post-update target partition and the ending position of the post-update target partition;

[0037] If the post-traversal key value position is used to indicate that the target partition key value exists after the post-target partition termination position, the post-dynamic partition step size is increased to obtain an increased post-dynamic partition step size, and the post-target partition termination position is updated according to the partition termination position, the increased post-dynamic partition step size and the post-partition step size constant to obtain an updated post-target partition termination position;

[0038] The target partition key value is positionally looped between the post-target partition start position and the updated post-target partition end position until the target partition key value exists between the post-target partition start position and the updated post-target partition end position.

[0039] In some embodiments, partitioning the target partition key value according to the traversal key value position, the target partition start position, and the target partition end position to obtain the target database partition includes:

[0040] If the traversal key value position is the preceding traversal key value position, partition creation is performed on the target partition key value according to the preceding target partition start position and the preceding target partition end position to obtain the target database partition;

[0041] If the traversal key value position is the centered traversal key value position, partitioning the target partition key value is performed according to the first centered target partition starting position, the second centered target partition starting position and the centered target partition ending position to obtain the target database partition;

[0042] If the traversal key value position is the post-traversal key value position, the target partition key value is partitioned and created according to the post-target partition start position and the post-target partition end position to obtain the target database partition.

[0043] To achieve the above-mentioned purpose, a second aspect of an embodiment of the present application provides a database partitioning device, the device comprising:

[0044] A partition key value acquisition module is used to obtain the target partition key value;

[0045] A partition interval module, used to obtain the current database partition and the partition interval of the current database partition; wherein the partition interval includes the partition start position and the partition end position of each current database partition;

[0046] A position identification module, used to identify the position of the target partition key value according to the partition start position and the partition end position, so as to obtain the partition key value position;

[0047] A target partition position acquisition module, used to determine a target partition start position and a target partition end position based on a preset dynamic partition step, the partition start position, the partition end position and the partition key value position;

[0048] A position loop traversal module, used for performing a position loop traversal on the target partition key value between the target partition start position and the target partition end position according to the partition key value position, to obtain a traversal key value position;

[0049] The partition creation module is used to create a partition for the target partition key value according to the traversal key value position, the target partition starting position and the target partition ending position to obtain a target database partition.

[0050] To achieve the above objectives, a third aspect of an embodiment of the present application proposes an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the method described in the first aspect is implemented.

[0051] To achieve the above-mentioned purpose, the fourth aspect of an embodiment of the present application proposes a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in the first aspect is implemented.

[0052] The database partitioning method and device, electronic device and storage medium proposed in the present application obtain a target partition key value; obtain a current database partition, and obtain a partition interval of the current database partition; wherein the partition interval includes a partition start position and a partition end position of each current database partition; identify the position of the target partition key value according to the partition start position and the partition end position to obtain the partition key value position; determine the target partition start position and the target partition end position based on a preset dynamic partition step, a partition start position, a partition end position and a partition key value position; according to the partition key value position, perform a position loop traversal of the target partition key value between the target partition start position and the target partition end position to obtain the traversal key value position; partition the target partition key value according to the traversal key value position, the target partition start position and the target partition end position to obtain the target database partition. The present application identifies the position of the target partition key value according to the partition start position and the partition end position, and can determine whether the target partition key value is located before, in the middle or after the existing database partition, which can facilitate the subsequent targeted positioning of the target database partition in different existing database partition positions for the target partition key value, so as to improve the efficiency of database partitioning; and according to the partition key value position, the target partition key value is positionally looped and traversed between the target partition start position and the target partition end position, and the dynamic partition step can be adjusted for different partition key value positions, and the target partition key value is positionally identified in combination with the partition start position, the partition end position and the traversed key value position, so that the interval position of the target database partition to be created can be quickly located, thereby improving the efficiency of database partitioning. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] Figure 1 is a flowchart of a database partitioning method provided in an embodiment of the present application;

[0054] Figure 2 yes Figure 1 Flow chart of step S103 in FIG.

[0055] Figure 3 yes Figure 1 Flow chart of step S104 in FIG.

[0056] Figure 4 yes Figure 3 Flow chart of step S301 in FIG.

[0057] Figure 5 yes Figure 3 Flow chart of step S302 in FIG.

[0058] Figure 6 yes Figure 3 Flow chart of step S303 in FIG.

[0059] Figure 7 It is a structural schematic diagram of a database partitioning device provided in an embodiment of the present application;

[0060] Figure 8 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION

[0061] 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.

[0062] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0063] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0064] Based on this, the embodiments of the present application provide a database partitioning method and device, an electronic device, and a storage medium, aiming to improve the efficiency of database partitioning.

[0065] The database partitioning method and device, electronic device and storage medium provided in the embodiments of the present application are specifically described through the following embodiments. First, the database partitioning method in the embodiments of the present application is described.

[0066] The database partitioning method provided in the embodiment of the present application relates to the fields of financial technology and data processing technology. The database partitioning method provided in the embodiment of the present application can be applied to the terminal, can also be applied to the server side, and can also be software running in the terminal or the server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or it can be configured as a server cluster or distributed system composed of multiple physical servers, and can also be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the database partitioning method, etc., but is not limited to the above forms.

[0067] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.

[0068] Figure 1 is an optional flowchart of the database partitioning method provided in an embodiment of the present application. Figure 1 The method may include but is not limited to steps S101 to S106.

[0069] Step S101, obtaining a target partition key value.

[0070] Step S102, obtaining the current database partition and the partition interval of the current database partition; wherein the partition interval includes the partition start position and the partition end position of each current database partition.

[0071] Step S103, identifying the location of the target partition key value according to the partition start position and the partition end position to obtain the partition key value location.

[0072] Step S104, determining a target partition start position and a target partition end position based on a preset dynamic partition step, a partition start position, a partition end position and a partition key value position.

[0073] Step S105 , determining a target partition start position and a target partition end position based on a preset dynamic partition step, a partition start position, a partition end position and a partition key value position.

[0074] Step S106, creating a partition for the target partition key value according to the traversal key value position, the target partition start position and the target partition end position to obtain a target database partition.

[0075] Steps S101 to S106 shown in the embodiment of the present application are as follows: obtaining a target partition key value; obtaining a current database partition, and obtaining a partition interval of the current database partition; wherein the partition interval includes a partition start position and a partition end position of each current database partition; identifying the position of the target partition key value according to the partition start position and the partition end position to obtain a partition key value position; determining the target partition start position and the target partition end position based on a preset dynamic partition step, a partition start position, a partition end position, and a partition key value position; according to the partition key value position, performing a position loop traversal of the target partition key value between the target partition start position and the target partition end position to obtain a traversal key value position; partitioning the target partition key value according to the traversal key value position, the target partition start position, and the target partition end position to obtain a target database partition. The present application identifies the position of the target partition key value according to the partition start position and the partition end position, and can determine whether the target partition key value is located before, in the middle or after the existing database partition, which can facilitate the subsequent targeted positioning of the target database partition in different existing database partition positions for the target partition key value, so as to improve the efficiency of database partitioning; and according to the partition key value position, the target partition key value is positionally looped and traversed between the target partition start position and the target partition end position, and the dynamic partition step can be adjusted for different partition key value positions, and the target partition key value is positionally identified in combination with the partition start position, the partition end position and the traversed key value position, so that the interval position of the target database partition to be created can be quickly located, thereby improving the efficiency of database partitioning.

[0076] In step S101 of some embodiments, specifically, the target partition key value refers to a specific data value that needs to be located or inserted in the partition structure of the database, and in range partitioning, the target partition key value is usually a quantitative indicator such as a timestamp or an amount.

[0077] For example, in the insurance field, the target partition key value can be the insurance policy effective date, the insurance claim date, the insurance claim amount, the insurance payment amount or the insurance policy number. If the insurance policy effective date is June 28, 2024, but the current database partition is only until June 14, 2024, you can create a new database partition to store June 28, 2024.

[0078] Specifically, the target partition key value may be obtained from the enterprise backend database.

[0079] In step S102 of some embodiments, current database partitioning refers to distributing data into different parts according to data storage rules, and each part is called a partition. The storage rule may be a rule for dividing data based on timestamps or financial value ranges.

[0080] Specifically, the current database partition includes an existing partition, wherein the existing partition refers to a partition that already exists in the current database.

[0081] Specifically, existing partitions can be divided according to certain range rules.

[0082] For example, in the insurance company's database, due to the huge amount of insurance policy data, in order to improve the efficiency of policy query and write operations, database partitioning is usually used to manage and maintain this data. The insurance company can use the insurance transaction date as the storage rule, and divide the insurance policies with insurance transaction dates between January 15, 2023 and February 14, 2023 into one partition, and divide the insurance policies with insurance transaction dates between February 15, 2023 and March 14, 2023 into another partition. These partitions can be stored independently on different physical disks or database nodes.

[0083] Specifically, the partition interval refers to the data range stored in the database partition, and the partition interval includes the partition start position and partition end position of each current database partition. The partition start position refers to the starting point of the data range stored in a current database partition; the partition end position refers to the end point of the data range stored in a current database partition.

[0084] Specifically, metadata of the current partition can be obtained by performing a metadata query on the current database partition; partition interval position analysis can be performed on the current partition metadata to obtain the partition start position and partition end position.

[0085] Specifically, you can write an SQL query statement (such as tnformatton_schema.parttttons) to query the metadata table of the current database partition, return the partition name and partition description of all current database partitions through the metadata table, parse the partition description according to the partition name to get the partition range, and extract the partition start position and partition end position from the partition range.

[0086] For example, in an insurance transaction database partitioned according to the insurance transaction date range, there is a current database partition with a partition interval from January 15, 2023 to February 14, 2023. The partition start position is January 15, 2023, and the partition end position is February 14, 2023.

[0087] In step S103 of some embodiments, the partition key value position refers to the position of the target partition key value relative to the current database partition.

[0088] Specifically, the partition key value position is used to indicate: the target partition key value is before the partition start position, the target partition key value is between the partition start position and the partition end position, and the target partition key value is after the partition end position.

[0089] See also Figure 2 In some embodiments, step S103 may include but is not limited to steps S201 to S203:

[0090] Step S201, performing a post-position detection on the target partition key value according to the partition termination position to obtain the post-position partition key value position.

[0091] Step S202: Perform a leading position detection on the target partition key value according to the partition start position to obtain the leading partition key value position.

[0092] Step S203: perform a center position detection on the target partition key value according to the partition start position and the partition end position to obtain the center partition key value position.

[0093] In step S201 of some embodiments, the post-partition key value position refers to the target partition key value being located after the partition end position.

[0094] Specifically, the partition end position is the last partition end position of the last existing database partition in the current database partition.

[0095] Specifically, performing post-position detection on the target partition key value means comparing the target partition inter-key value with the last partition end position. If the target partition key value is after the last partition end position, the post-partition key value position is obtained.

[0096] For example, when a new insurance transaction record with a transaction date of May 15, 2023 is added, in order to determine in which partition the insurance transaction record should be stored, it is necessary to obtain the transaction time relative to the last existing partition in the current database partition, which is from April 15, 2023 to May 14, 2023, and the last partition end position is May 14, 2023. Since May 15, 2023 is after May 14, 2023, it is determined that the target partition key value is located after the partition end position.

[0097] In this embodiment, by performing post-position detection on the target partition key value according to the partition termination position, the target partition key value can be correctly located in the post-partition, which facilitates the subsequent targeted positioning of the target database partition, improves the efficiency of database partitioning, and can also ensure that the target partition key value is accurately located in the database partition, ensures the accuracy and consistency of the data, and improves the accuracy of database partitioning.

[0098] In step S202 of some embodiments, the leading partition key value position refers to the target partition key value being located before the partition start position.

[0099] Specifically, the partition start position is the first partition start position of the first existing database partition in the current database partition.

[0100] Specifically, performing a leading position detection on the target partition key value means comparing the target partition key value with the starting position of the first partition. If the target partition key value is before the starting position of the first partition, the leading partition key value position is obtained.

[0101] For example, when a new insurance transaction record with a transaction date of April 9, 2022 is added, in order to determine which partition the insurance transaction record should be stored in, it is necessary to obtain the transaction time relative to the first existing partition in the current database partition, which is from April 15, 2022 to May 14, 2022, and the starting position of the first partition is April 15, 2022. Since April 9, 2022 is before April 15, 2022, it is determined that the target partition key value is located before the starting position of the partition.

[0102] In step S203 of some embodiments, the middle partition key value position means that the target partition key value is located between the partition start position and the partition end position.

[0103] Specifically, the partition start position is the start position of any existing database partition in the current database partition except the first existing database partition; the partition end position is the end position of any existing database partition in the current database partition except the last existing database partition, and the partition end position is located before the adjacent partition start position of the next existing database partition.

[0104] Specifically, performing a center position detection on the target partition key value means comparing the target partition key value with the partition end position before the partition start position of the adjacent next existing database partition and the adjacent partition start position. If the target partition key value is between the partition end position before the partition start position of the adjacent next existing database partition and the adjacent partition start position, the center partition key value position is obtained.

[0105] For example, when a new insurance transaction record with a transaction date of May 15, 2023 is added, in order to determine in which partition the insurance transaction record should be stored, it is necessary to obtain the transaction time relative to the current database partition, which is from April 1, 2023 to April 30, 2023, and the partition end position is April 30, 2023. Since the database was overhauled in May 2023 and new forms were stopped from being entered, the transaction time relative to the adjacent existing database partition of the current database partition is from June 1, 2023 to June 30, 2023. Since May 15, 2023 is between April 30, 2023 and June 1, 2023, it is determined that the target partition key value is between the partition end position and the adjacent partition start position.

[0106] In this embodiment, by detecting the center position of the target partition key value according to the partition start position and the partition end position, it can be ensured that all data is recorded and stored, avoiding data loss or omission, ensuring data integrity, and improving the accuracy of subsequent database partitioning.

[0107] See also Figure 3 In some embodiments, step S104 may include but is not limited to steps S301 to S303:

[0108] Step S301, if the partition key value position is the preceding partition key value position, then the preceding dynamic partition step of the dynamic partition step is obtained according to the preceding partition key value position, the preceding target partition starting position is determined according to the partition initial position and the preceding dynamic partition step, and the partition initial position is used as the preceding target partition ending position.

[0109] Step S302, if the partition key value position is the center partition key value position, then the center dynamic partition step length of the dynamic partition step length is obtained according to the center partition key value position, the first center target partition starting position is determined according to the partition end position and the center dynamic partition step length, and the second center target partition starting position is determined based on the partition start position and the center dynamic partition step length, and the center target partition end position is determined according to the partition start position; the second center target partition starting position is greater than the first center target partition starting position;

[0110] Step S303, if the partition key value position is the post-partition key value position, then obtain the post-dynamic partition step of the dynamic partition step according to the post-partition key value position, determine the post-target partition starting position based on the partition end position and the post-dynamic partition step, obtain the post-partition step constant, and determine the post-target partition end position based on the post-dynamic partition step and the post-partition step constant.

[0111] In step S301 of some embodiments, the leading dynamic partition step refers to a dynamic unit of traversing the position of the target partition key value during the database partitioning process, and the leading dynamic partition step is used to locate the database target partition position where the target partition key value is located before the partition start position.

[0112] Specifically, the preceding target partition start position refers to the preceding start point of the target database partition storing the target partition key value; the preceding target partition end position refers to the preceding end point of the target database partition storing the target partition key value.

[0113] For example, when a new insurance transaction record with a transaction date of April 19, 2021 is added, in order to determine which partition the insurance transaction record should be stored in, it is necessary to obtain the transaction time relative to the starting position of the first partition, which is April 15, 2022. The first starting position is used as the end position of the preceding target partition. According to the partitioning rule that partitions the transaction dates from the 15th of last month to the 14th of this month, the initial position of the target partition can be determined as April 14, 2022 minus the preceding dynamic partition step.

[0114] See also Figure 4 In some embodiments, step S301 may include but is not limited to steps S401 to S403:

[0115] Step S401, perform a position loop traversal on the target partition key value between the starting position of the preceding target partition and the ending position of the preceding target partition to obtain the preceding traversal key value position; the preceding traversal key value position is used to indicate that the target partition key value exists between the starting position of the preceding target partition and the starting position of the preceding target partition or the target partition key value does not exist between the starting position of the preceding target partition and the starting position of the preceding target partition.

[0116] Step S402, if the preceding traversal key value position indicates that the target partition key value does not exist between the preceding target partition starting position and the preceding target partition starting position, the preceding dynamic partition step size is reduced to obtain a reduced preceding dynamic partition step size, and the preceding target partition starting position is used as the updating preceding target partition ending position, and the preceding target partition starting position is updated according to the updating preceding target partition ending position and the reducing preceding dynamic partition step size to obtain an updated preceding target partition starting position.

[0117] Step S403, performing a position loop traversal on the target partition key value between the start position of the updated previous target partition and the end position of the updated previous target partition, until the target partition key value exists between the start position of the updated previous target partition and the end position of the updated previous target partition.

[0118] In step S401 of some embodiments, the pre-traversal key value position is used to indicate that the target partition key value exists between the starting position of the pre-target partition and the starting position of the pre-target partition, or the target partition key value does not exist between the starting position of the pre-target partition and the starting position of the pre-target partition.

[0119] For example, to obtain the relevant position of the target partition key value t, if Y - Sq > t, it means that the target partition key value t is before Y - Sq. In the subsequent position loop traversal, the pre-partition dynamic step size needs to be reduced by half to obtain Sq1, and at the same time, the starting position of the pre-target partition is updated to Y + Sq1;

[0120] For example, if Y - Sq < t < Y, it means that the target partition key value t is between Y - Sq and Y. The starting position of the pre-target partition is determined to be Y - Sq, and the ending position of the pre-target partition is determined to be Y.

[0121] Wherein, Sq represents the pre-dynamic partition step size, t represents the target partition key value, and Y represents the starting position of the partition.

[0122] In this embodiment, by performing a position loop traversal of the target partition key value between the starting position of the pre-target partition and the ending position of the pre-target partition, it is possible to quickly locate the interval position of the target database partition to be created for the pre-target partition key value, improving the efficiency of the target database partition.

[0123] In step S402 of some embodiments, since the target partition key value does not exist between the starting position of the pre-target partition and the starting position of the pre-target partition, it means that the target partition key value is also located in an earlier partition of the initial position of the target partition, and it is necessary to further traverse the target partition by changing the pre-dynamic partition step size.

[0124] For example, the pre-dynamic partition step size is 6 months, and the initial position of the pre-target partition is October 14, 2021. If it is determined that the target partition key value of April 9, 2021 is not between the initial position of the pre-target partition of October 14, 2021 and the ending position of the pre-target partition of April 15, 2022, then the pre-dynamic partition step size of 6 months is reduced by half, and the pre-dynamic partition step size is determined to be 3 months. The initial position of the pre-target partition of October 14, 2021 is used as the updated ending position of the pre-target partition, and 3 months are subtracted from the updated ending position of the pre-target partition of October 14, 2021 to obtain the updated initial position of the target partition of July 14, 2021.

[0125] In this embodiment, for the data that does not exist between the starting position of the preceding target partition and the starting position of the preceding target partition, the step size of the preceding dynamic partition is reduced, which can reduce the number of position loop traversals, quickly locate the target database, and improve the efficiency of database partitioning. Moreover, as the number of traversals increases, the step size is correspondingly reduced, so that the target database partition can be accurately located during the traversal of the target key value, thereby improving the accuracy of data partitioning.

[0126] In step S403 of some embodiments, specifically, the target partition key value is re-looped between the starting position of updating the previous target partition and the ending position of updating the previous target partition to further determine the position of the target partition key value.

[0127] For example, the initial position of the updated target partition is July 14, 2021, the end position of the updated predecessor target partition is October 14, 2021, and the target partition key value is April 19, 2021, which is still not between the initial position of the updated predecessor target partition and the end position of the updated predecessor target partition. Sq is reduced to 2 months again, and the initial position of the updated predecessor target partition, July 14, 2021, is used as the end position of the updated predecessor target partition. The end position of the updated predecessor target partition, July 14, 2021, is subtracted by 2 months, and the initial position of the updated target partition is May 14, 2021.

[0128] Furthermore, since the target partition key value is still not between the starting position of the re-updated predecessor target partition and the ending position of the re-updated predecessor target partition, the step size of the predecessor dynamic partition is reduced to 1 month again, and the initial position of the re-updated predecessor target partition, May 14, 2021, is used as the ending position of the predecessor target partition for the next update. The ending position of the predecessor target partition for the next update, May 14, 2021, is subtracted by 1 month, and the initial position of the target partition for the next update is April 14, 2021. At this time, the target partition key value April 19, 2021 is between April 14, 2021 and May 14, 2021, and the position traversal loop ends.

[0129] In step S302 of some embodiments, the centered dynamic partition step refers to a dynamic unit of traversing the position of the target partition key value during the database partitioning process. The centered dynamic partition step is used to locate the database target partition position where the target partition key value is between the partition start position and the partition end position.

[0130] For example, when adding an insurance transaction record with a transaction date of May 15, 2023, in order to determine which partition the insurance transaction record should be stored in, it is necessary to obtain the first partition from April 15, 2022 to May 14, 2022, and the second partition from June 15, 2023 to July 14, 2023.

[0131] Furthermore, the end position of the first partition, May 14, 2022, is added to the center dynamic partition step of 4 months to determine the starting position of the first center target partition as September 14, 2022; the starting position of the second partition is subtracted from the center dynamic partition step of 4 months to determine the starting position of the second center target partition as December 15, 2022, and June 15, 2023 is used as the end position of the center target partition.

[0132] See also Figure 5 In some embodiments, step S302 may include but is not limited to steps S501 to S505:

[0133] Step S501, perform a position loop traversal on the target partition key value between the first centered target partition starting position, the second centered target partition starting position and the centered target partition ending position to obtain the centered traversal key value position; the centered traversal key value position is used to indicate that the target partition key value exists between the first centered target partition starting position and the second centered target partition starting position, or the target partition key value exists before the first centered target partition starting position, or the target partition key value exists between the second centered target partition starting position and the centered target partition ending position.

[0134] Step S502, if the centered traversal key value position is used to indicate that the target partition key value exists before the starting position of the first centered target partition, the centered dynamic partition step size is increased to obtain an increased centered dynamic partition step size, and the starting position of the first centered target partition is updated according to the partition end position and the increased centered dynamic partition step size to obtain an updated starting position of the first centered target partition.

[0135] Step S503, performing a position loop traversal on the target partition key value between the updated first centered target partition start position and the updated second centered target partition start position until the target partition key value exists between the updated first centered target partition start position and the updated second centered target partition start position.

[0136] Step S504: If the centered traversal key value position indicates that the target partition key value exists between the starting position of the second centered target partition and the ending position of the centered target partition, then reduce the centered dynamic partition step size to obtain a reduced centered dynamic partition step size, and update the starting position of the second centered target partition according to the partition starting position and the reduced centered dynamic partition step size to obtain an updated starting position of the second centered target partition.

[0137] Step S505: Perform a position loop traversal of the target partition key value between the updated starting position of the second centered target partition and the ending position of the centered target partition until the target partition key value exists between the updated starting position of the second centered target partition and the ending position of the centered target partition.

[0138] In step S501 of some embodiments, the centered traversal key value position indicates that the target partition key value exists between the starting position of the first centered target partition and the starting position of the second centered target partition, or the target partition key value exists before the starting position of the first centered target partition, or the target partition key value exists between the starting position of the second centered target partition and the ending position of the centered target partition.

[0139] For example, obtain the relevant position of the target partition key value t. If t is between X1 + Sj and X2 - Sj, then the starting position of the first centered target partition is X1 + Sj, and the starting position of the second centered target partition is X2 - Sj.

[0140] For example, if X1 + Sj > t, it means that the target partition key value t is before X1 + Sj. In the subsequent position loop traversal, the centered partition dynamic step size needs to be doubled to obtain Sj1, and at the same time, update the starting position of the first centered target partition to X1 - Sj;

[0141] For example, if X2 - Sj < t, it means that the target partition key value t is after X2 - Sj. In the subsequent position loop traversal, the centered partition dynamic step size needs to be reduced by half to obtain Sj2, and at the same time, update the starting position of the second centered target partition to X2 + Sj.

[0142] Among them, Sj represents the centered dynamic partition step size, t represents the target partition key value, X1 represents the partition starting position, and X2 represents the partition ending position.

[0143] In this embodiment, by performing a position loop traversal of the target partition key value between the starting position of the first centered target partition, the starting position of the second centered target partition, and the ending position of the centered target partition, it is possible to quickly locate the position of the target database partition for the centered traversal key value position, improving the database partition efficiency.

[0144] In step S502 of some embodiments, since the target partition key value does not exist between the starting position of the first centered target partition and the starting position of the second centered target partition, it means that the target partition key value is still located in an earlier partition, or a partition located later than the starting position of the second centered target partition needs to further traverse the target partition by changing the centered dynamic partition step size.

[0145] For example, the target partition key value is May 15, 2023, and the starting position of the first centered target partition is September 15, 2023. It is determined that the target partition key value is before the starting position of the first centered target partition. The step length of the centered dynamic partition is doubled by 3 months, and the step length of the centered dynamic partition is determined to be 6 months. 6 months are subtracted from March 15, 2023, and the starting position of the updated first centered target partition is determined to be March 15, 2023.

[0146] In this embodiment, when the target partition key value exists before the starting position of the first centered target partition, the centered dynamic step size is increased, which can speed up the traversal rate of the target partition key value without the need to perform position loop traversal step by step, thereby significantly improving the database partitioning efficiency.

[0147] In step S503 of some embodiments, the target partition key value is re-looped between updating the first center target partition start position and the second center target partition start position to further determine the position of the target partition key value.

[0148] For example, the target partition key value is May 15, 2023, the starting position of the updated first centered target partition is March 15, 2023, and the second centered target partition position is December 15, 2023. It is determined that the target partition key value is between the starting position of the updated first centered target partition and the starting position of the second centered target partition, and the position loop traversal ends.

[0149] In step S504 of some embodiments, since the target partition key value exists between the starting position of the second centered target partition and the ending position of the centered target partition, it means that the target partition key value is located in a partition later than the starting position of the second centered target partition, and it is necessary to further traverse the target partition by changing the step size of the centered dynamic partition.

[0150] For example, the target partition key value is May 15, 2023, the starting position of the second center target partition is March 15, 2023, and the ending position of the center target partition is December 15, 2023. It is determined that the target partition key value is between the starting position of the second center target partition and the ending position of the center target partition. The center dynamic partition step of 4 months is reduced by half to determine that the center dynamic partition step is 2 months, and March 15, 2023 is added with 2 months to determine that the starting position of the second center target partition is updated to May 15, 2023.

[0151] In this embodiment, the target partition key value exists between the starting position of the second center target partition and the ending position of the center target partition, combined with the reduction of the center dynamic partition step, while reducing the number of loops, the closer to the target partition key value, the smaller the traversal range, thereby ensuring the accuracy of the target database partition found.

[0152] In step S505 of some embodiments, the target partition key value is re-looped between updating the start position of the second center target partition and the end position of the center target partition to further determine the position of the target partition key value.

[0153] For example, the target partition key value is May 15, 2023, the starting position of the second center target partition to be updated is May 15, 2023, and the ending position of the center target partition is December 15, 2023. It is determined that the target partition key value is between the starting position of the second center target partition to be updated and the ending position of the center target partition, and the position loop traversal ends.

[0154] In step S303 of some embodiments, the post-dynamic partition step refers to a dynamic unit of traversing the position of the target partition key value during the database partitioning process, and the post-dynamic partition step is used to locate the database target partition position where the target partition key value is located after the partition termination position.

[0155] For example, when a new insurance transaction record with a transaction date of April 19, 2023 is added, in order to determine in which partition the insurance transaction record should be stored, the last existing partition from April 15, 2022 to May 14, 2022 is obtained.

[0156] Furthermore, the partition end position May 14, 2022, is added to the post-dynamic partition step of 2 months, and the post-target partition starting position is determined to be July 14, 2022; the post-partition step constant is 2 months, and the partition end position May 14, 2022, the post-dynamic partition step of 2 months and the post-partition step constant of 2 months are added to determine the post-target partition end position to be September 14, 2022.

[0157] See also Figure 6 In some embodiments, step S303 may include but is not limited to steps S601 to S605:

[0158] Step S601, perform a position loop traversal on the target partition key value between the post-target partition start position and the post-target partition end position to obtain the post-traversal key value position; the post-traversal key value position is used to indicate that the target partition key value exists between the post-target partition start position and the post-target partition end position, or the target partition key value exists before the post-target partition start position, or the target partition key value exists after the post-target partition end position.

[0159] Step S602, if the post-traversal key value position is used to indicate that the target partition key value exists before the post-target partition starting position, the post-dynamic partition step size is reduced to obtain a reduced post-dynamic partition step size, and the post-target partition starting position is updated according to the partition end position and the reduced post-dynamic partition step size to obtain an updated post-target partition starting position.

[0160] Step S603, performing a position loop traversal on the target partition key value between the start position of the post-update target partition and the end position of the post-update target partition, until the target partition key value exists between the start position of the post-update target partition and the end position of the post-update target partition.

[0161] Step S604, if the post-traversal key value position is used to indicate that the target partition key value exists after the post-target partition termination position, the post-dynamic partition step size is increased to obtain an increased post-dynamic partition step size, and the post-target partition termination position is updated according to the partition termination position, the increased post-dynamic partition step size and the post-partition step size constant to obtain an updated post-target partition termination position.

[0162] Step S605 , looping through the target partition key value between the post-target partition start position and the post-target partition update end position until the target partition key value exists between the post-target partition start position and the post-target partition update end position.

[0163] In step S601 of some embodiments, the post-traversal key value position is used to indicate that the target partition key value exists between the post-target partition start position and the post-target partition end position, or the target partition key value exists before the post-target partition start position, or the target partition key value exists after the post-target partition end position.

[0164] For example, obtain the relative position of P+Sd and the target partition key value t. If t is between P+Sd and P+Sd+Sc, the starting position of the post-target partition is P+Sd, and the ending position of the post-target partition is P+Sd+Sc.

[0165] For example, if P + Sd + Sc < t, it means that the target partition key value t is after P + Sd + Sc. The post - partition dynamic step size needs to be doubled to Sd1, and at the same time, the termination position of the post - target partition is updated to P + Sd1 + Sc;

[0166] For example, if P + Sd > t, it means that the target partition key value t is before P + Sd. The dynamic step size needs to be reduced to Sd2, and at the same time, the start position of the post - target partition is updated to P + Sd2.

[0167] Among them, P represents the partition termination position, Sd represents the post - partition dynamic step size, t represents the target partition key value, Sc represents the post - partition step size constant, and Sd is n times of Sc.

[0168] In this embodiment, by cyclically traversing the position of the target partition key value between the start position of the post - target partition and the termination position of the post - target partition, it is possible to specifically perform a cyclic position traversal for the post - target partition key value, reducing the number of loops and improving the efficiency of database partitioning.

[0169] In step S602 of some embodiments, since P + Sd > t, it means that the target partition key value t is before P + Sd. The target partition needs to be further traversed by reducing the dynamic partition step size.

[0170] For example, the target partition key value is May 15, 2023, the post - partition dynamic step size Sd is 4 months, and the start position of the post - target partition is September 15, 2023. It is determined that May 15, 2023 is before September 15, 2023. Then the post - partition dynamic step size Sd is reduced by half, Sd2 is determined to be 2 months, and September 15, 2023 is subtracted by 2 months. It is determined that the updated start position of the post - target partition is July 15, 2023.

[0171] In step S603 of some embodiments, the position of the target partition key value is cyclically traversed again between the updated start position of the post - target partition and the termination position of the post - target partition to further determine the position where the target partition key value is located.

[0172] For example, the target partition key value is May 15, 2023, the updated start position of the first centered target partition is July 15, 2023. It is determined that May 15, 2023 is still before July 15, 2023. Sd2 is reduced by half again to 1 month, and July 15, 2023 is subtracted by 1 month. It is determined that the start position of the post - target partition is updated again to June 15, 2023.

[0173] Furthermore, since May 15, 2023 is still before June 15, 2023, the partitioning rule is based on one-month partitioning, so Sd2 is kept at 1 month, and 1 month is subtracted from June 15, 2023, and the starting position of the updated post-target partition is determined to be May 15, 2023, and the target partition key value is determined to be between the starting position of the updated post-target partition and the ending position of the post-target partition, and the position loop traversal ends.

[0174] In step S604 of some embodiments, since the target partition key value exists after the end position of the subsequent target partition, it means that the target partition key value is located in a partition later than the end position of the subsequent target partition, and it is necessary to further traverse the target partition by increasing the step size of the subsequent dynamic partition.

[0175] For example, the target partition key value is May 15, 2023, and the end position of the post-target partition is February 15, 2023. Since the post-dynamic step Sd is 1 month and the post-dynamic constant Sc is 1 month, it is determined that May 15, 2023 is after February 15, 2023. The post-dynamic partition step Sd is doubled to obtain Sd1 of 2 months. January 15, 2023 is added to 2 months of Sd1 and 1 month of Sc to determine that the end position of the updated post-target partition is May 15, 2023.

[0176] In step S605 of some embodiments, the target partition key value is re-looped between the post-target partition start position and the updated post-target partition end position to further determine the position of the target partition key value.

[0177] For example, the target partition key value is May 15, 2023, the end position of the updated post-target partition is May 15, 2023, and the start position of the post-target partition is April 15, 2023. It is determined that the target partition key value is between the start position of the post-target partition and the end position of the updated post-target partition, and the position loop traversal ends.

[0178] In step S106 of some embodiments, the target database partition refers to a database partition storing the target partition key value.

[0179] For example, the insurance policy takes effect on June 28, 2024, but the current database partition only extends to June 14, 2024. In this case, you can create a new database partition from June 15, 2024 to July 14, 2024 to store June 28, 2024.

[0180] Specifically, if the traversal key value position is the preceding traversal key value position, a partition is created for the target partition key value based on the preceding target partition start position and the preceding target partition end position to obtain a target data partition.

[0181] Specifically, partitions can be created based on partition strategies and partition rules. Partition strategies refer to database partition types, such as range partitions, hash partitions, etc. Partition rules refer to the instructions for database partitions, which are determined based on business conditions.

[0182] For example, the partitioning strategy of the database partition is range partitioning. At this time, it is necessary to store insurance policies with an effective date of June 28, 2022. Since the current database partition only stores insurance policies from January 1, 2023 to January 31, 2023 at the earliest, the partitioning rule is to create partitions based on the policy effective date interval of 1 month. In this case, a target database partition from June 1, 2022 to June 30, 2022 is created, and the insurance policies on June 28, 2022 are stored in the target database partition.

[0183] If the traversal key value position is a centered traversal key value position, the target partition key value is partitioned and created according to the first centered target partition starting position, the second centered target partition starting position and the centered target partition ending position to obtain a target data partition.

[0184] For example, the partitioning strategy of the database partition is range partitioning. At this time, it is necessary to store insurance policies with an effective date of June 28, 2022. Since the first partition in the existing database partition stores insurance policies from May 1, 2022 to May 31, 2022, and the second partition adjacent to the first partition stores insurance policies from July 1, 2022 to July 31, 2022, the partitioning rule is to create partitions based on the policy effective date interval of 1 month. In this case, a target database partition from June 1, 2022 to June 30, 2022 is created, and the insurance policies on June 28, 2022 are stored in the target database partition.

[0185] If the traversal key value position is a post-traversal key value position, a partition is created for the target partition key value based on the post-target partition start position and the post-target partition end position to obtain a target data partition.

[0186] For example, the partitioning strategy of the database partition is range partitioning. At this time, a new insurance policy with policy number 30001 needs to be inserted, and the current largest partition only contains data with policy numbers to 30000. The partitioning rule is to create partitions based on policy numbers with an interval of 10000. In this case, a target database partition from 30001 to 40000 is created, and the insurance policy with policy number 30001 is stored in the target database partition.

[0187] The embodiment of the present application obtains a target partition key value; obtains a current database partition, and obtains a partition interval of the current database partition; wherein the partition interval includes a partition start position and a partition end position of each current database partition; identifies the position of the target partition key value according to the partition start position and the partition end position to obtain a partition key value position; determines the target partition start position and the target partition end position based on a preset dynamic partition step, a partition start position, a partition end position, and a partition key value position; according to the partition key value position, performs a position loop traversal of the target partition key value between the target partition start position and the target partition end position to obtain a traversal key value position; creates a partition for the target partition key value according to the traversal key value position, the target partition start position, and the target partition end position to obtain a target database partition. The present application identifies the position of the target partition key value according to the partition start position and the partition end position, and can determine whether the target partition key value is located before, in the middle or after the existing database partition, which can facilitate the subsequent targeted positioning of the target database partition in different existing database partition positions for the target partition key value, so as to improve the efficiency of database partitioning; and according to the partition key value position, the target partition key value is positionally looped and traversed between the target partition start position and the target partition end position, and the dynamic partition step can be adjusted for different partition key value positions, and the target partition key value is positionally identified in combination with the partition start position, the partition end position and the traversed key value position, so that the interval position of the target database partition to be created can be quickly located, thereby improving the efficiency of database partitioning.

[0188] See also Figure 7 The embodiment of the present application also provides a database partitioning device, which can implement the above database partitioning method, and the device includes:

[0189] A partition key value acquisition module is used to obtain the target partition key value;

[0190] A partition interval module is used to obtain the current database partition and the partition interval of the current database partition; wherein the partition interval includes the partition start position and the partition end position of each current database partition;

[0191] A position identification module is used to identify the position of the target partition key value according to the partition start position and the partition end position to obtain the partition key value position;

[0192] A target partition position acquisition module is used to determine the target partition start position and the target partition end position based on a preset dynamic partition step, a partition start position, a partition end position and a partition key value position;

[0193] A position loop traversal module is used to perform a position loop traversal on the target partition key value between the target partition start position and the target partition end position according to the partition key value position, so as to obtain the traversal key value position;

[0194] The partition creation module is used to create a partition for the target partition key value according to the traversal key value position, the target partition start position and the target partition end position to obtain the target database partition.

[0195] The specific implementation of the database partitioning device is substantially the same as the specific implementation of the above-mentioned database partitioning method, and will not be described in detail herein.

[0196] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above database partitioning method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.

[0197] See also Figure 8 , Figure 8 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:

[0198] The processor 801 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, AStC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;

[0199] The memory 802 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 802 can store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 802, and the processor 801 calls and executes the database partitioning method of the embodiment of this application;

[0200] Input / output interface 803, used to implement information input and output;

[0201] The communication interface 804 is used to realize the communication interaction between the device and other devices. The communication can be realized through a wired manner (such as USB, network cable, etc.) or a wireless manner (such as mobile network, WtFt, Bluetooth, etc.);

[0202] A bus 805 that transmits information between the various components of the device (e.g., the processor 801, the memory 802, the input / output interface 803, and the communication interface 804);

[0203] The processor 801 , the memory 802 , the input / output interface 803 and the communication interface 804 are connected to each other in communication within the device via a bus 805 .

[0204] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned database partitioning method is implemented.

[0205] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0206] The database partitioning method, database partitioning device, electronic device and storage medium provided by the embodiments of the present application obtain a target partition key value; obtain a current database partition, and obtain a partition interval of the current database partition; wherein the partition interval includes a partition start position and a partition end position of each current database partition; according to the partition start position and the partition end position, the position of the target partition key value is identified to obtain a partition key value position; based on a preset dynamic partition step, a partition start position, a partition end position and a partition key value position, a target partition start position and a target partition end position are determined; according to the partition key value position, a position loop traverses the target partition key value between the target partition start position and the target partition end position to obtain a traversal key value position; according to the traversal key value position, a partition is created for the target partition key value to obtain a target database partition. The present application identifies the position of the target partition key value according to the partition start position and the partition end position, and can determine whether the target partition key value is located before, in the middle or after the existing database partition, which can facilitate the subsequent targeted positioning of the target database partition in different existing database partition positions for the target partition key value, so as to improve the efficiency of database partitioning; and according to the partition key value position, the target partition key value is positionally looped and traversed between the target partition start position and the target partition end position, and the dynamic partition step can be adjusted for different partition key value positions, and the target partition key value is positionally identified in combination with the partition start position, the partition end position and the traversed key value position, so that the interval position of the target database partition to be created can be quickly located, thereby improving the efficiency of database partitioning.

[0207] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0208] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.

Claims

1. A database partitioning method, characterized in that: The method comprises: Get the target partition key value; Obtaining a current database partition and obtaining a partition interval of the current database partition; wherein the partition interval includes a partition start position and a partition end position of each current database partition; According to the partition start position and the partition end position, the target partition key value is identified to obtain the partition key value position; Determine a target partition start position and a target partition end position based on a preset dynamic partition step, the partition start position, the partition end position and the partition key value position; According to the partition key value position, the target partition key value is positionally traversed between the target partition start position and the target partition end position to obtain a traversed key value position; The target partition key value is partitioned and created according to the traversal key value position, the target partition starting position and the target partition ending position to obtain a target database partition.

2. The method according to claim 1, characterized in that The partition key value position is used to indicate that: the target partition key value is located before the partition start position, the target partition key value is located between the partition start position and the partition end position, and the target partition key value is located after the partition end position; The step of identifying the position of the target partition key value according to the partition start position and the partition end position to obtain the partition key value position includes: Performing a post-position detection on the target partition key value according to the partition termination position to obtain the post-position partition key value position; Performing a leading position detection on the target partition key value according to the partition starting position to obtain the leading partition key value position; The target partition key value is detected at a center position according to the partition start position and the partition end position to obtain the center partition key value position.

3. The method according to claim 2, characterized in that The determining of the target partition start position and the target partition end position based on the preset dynamic partition step, the partition start position, the partition end position and the partition key value position includes: If the partition key value position is the preceding partition key value position, the preceding dynamic partition step of the dynamic partition step is obtained according to the preceding partition key value position, the preceding target partition starting position is determined according to the partition initial position and the preceding dynamic partition step, and the partition initial position is used as the preceding target partition ending position; If the partition key value position is the centered partition key value position, the centered dynamic partition step of the dynamic partition step is obtained according to the centered partition key value position, the first centered target partition starting position is determined according to the partition ending position and the centered dynamic partition step, and the second centered target partition starting position is determined based on the partition starting position and the centered dynamic partition step, and the centered target partition ending position is determined according to the partition starting position; the second centered target partition starting position is greater than the first centered target partition starting position; If the partition key value position is a post-partition key value position, the post-dynamic partition step of the dynamic partition step is obtained according to the post-partition key value position, the post-target partition starting position is determined based on the partition end position and the post-dynamic partition step, the post-partition step constant is obtained, and the post-target partition end position is determined based on the post-dynamic partition step and the post-partition step constant.

4. The method according to claim 3, characterized in that If the partition key value position is the preceding partition key value position; The step of performing a position loop traversal on the target partition key value between the target partition start position and the target partition end position according to the partition key value position to obtain the traversal key value position includes: The target partition key value is positionally traversed between the starting position of the preceding target partition and the ending position of the preceding target partition to obtain the preceding traversal key value position; the preceding traversal key value position is used to indicate that the target partition key value exists between the starting position of the preceding target partition and the starting position of the preceding target partition or that the target partition key value does not exist between the starting position of the preceding target partition and the starting position of the preceding target partition; If the preceding traversal key value position indicates that the target partition key value does not exist between the preceding target partition starting position and the preceding target partition starting position, the preceding dynamic partition step size is reduced to obtain a reduced preceding dynamic partition step size, and the preceding target partition starting position is used as an updated preceding target partition terminating position, and the preceding target partition starting position is updated according to the updated preceding target partition terminating position and the reduced preceding dynamic partition step size to obtain an updated preceding target partition starting position; The target partition key value is positionally looped between the update preceding target partition start position and the update preceding target partition end position until the target partition key value exists between the update preceding target partition start position and the update preceding target partition end position.

5. The method according to claim 4, characterized in that If the partition key value position is the center partition key value position; The step of performing a position loop traversal on the target partition key value between the target partition start position and the target partition end position according to the partition key value position to obtain the traversal key value position includes: The target partition key value is positionally traversed between the first centered target partition starting position, the second centered target partition starting position and the centered target partition ending position to obtain the centered traversal key value position; the centered traversal key value position is used to indicate that the target partition key value exists between the first centered target partition starting position and the second centered target partition starting position, or the target partition key value exists before the first centered target partition starting position, or the target partition key value exists between the second centered target partition starting position and the centered target partition ending position; If the centered traversal key value position is used to indicate that the target partition key value exists before the first centered target partition starting position, the centered dynamic partition step size is increased to obtain an increased centered dynamic partition step size, and the first centered target partition starting position is updated according to the partition end position and the increased centered dynamic partition step size to obtain an updated first centered target partition starting position; Performing a position loop traversal of the target partition key value between the updated first centered target partition starting position and the second centered target partition starting position until the target partition key value exists between the updated first centered target partition starting position and the second centered target partition starting position; If the centered traversal key value position is used to indicate that the target partition key value exists between the second centered target partition starting position and the centered target partition ending position, the centered dynamic partition step size is reduced to obtain the reduced centered dynamic partition step size, and the second centered target partition starting position is updated according to the partition starting position and the reduced centered dynamic partition step size to obtain an updated second centered target partition starting position; The target partition key value is positionally looped between the start position of the updated second centered target partition and the end position of the centered target partition until the target partition key value exists between the start position of the updated second centered target partition and the end position of the centered target partition.

6. The method according to claim 5, characterized in that If the partition key value position is the post-partition key value position; The step of performing a position loop traversal on the target partition key value between the target partition start position and the target partition end position according to the partition key value position to obtain the traversal key value position includes: The target partition key value is positionally traversed between the post-target partition start position and the post-target partition end position to obtain the post-traversal key value position; the post-traversal key value position is used to indicate that the target partition key value exists between the post-target partition start position and the post-target partition end position, or the target partition key value exists before the post-target partition start position, or the target partition key value exists after the post-target partition end position; If the post-traversal key value position is used to indicate that the target partition key value exists before the post-target partition starting position, the post-dynamic partition step size is reduced to obtain a reduced post-dynamic partition step size, and the post-target partition starting position is updated according to the partition end position and the reduced post-dynamic partition step size to obtain an updated post-target partition starting position; Performing a position loop traversal of the target partition key value between the starting position of the post-update target partition and the ending position of the post-update target partition until the target partition key value exists between the starting position of the post-update target partition and the ending position of the post-update target partition; If the post-traversal key value position is used to indicate that the target partition key value exists after the post-target partition termination position, the post-dynamic partition step size is increased to obtain an increased post-dynamic partition step size, and the post-target partition termination position is updated according to the partition termination position, the increased post-dynamic partition step size and the post-partition step size constant to obtain an updated post-target partition termination position; The target partition key value is positionally looped between the post-target partition start position and the updated post-target partition end position until the target partition key value exists between the post-target partition start position and the updated post-target partition end position.

7. The method according to claim 6, characterized in that The step of creating a partition for the target partition key value according to the traversal key value position, the target partition start position, and the target partition end position to obtain a target database partition includes: If the traversal key value position is the preceding traversal key value position, partition creation is performed on the target partition key value according to the preceding target partition start position and the preceding target partition end position to obtain the target database partition; If the traversal key value position is the centered traversal key value position, partitioning the target partition key value is performed according to the first centered target partition starting position, the second centered target partition starting position and the centered target partition ending position to obtain the target database partition; If the traversal key value position is the post-traversal key value position, the target partition key value is partitioned and created according to the post-target partition start position and the post-target partition end position to obtain the target database partition.

8. A database partitioning device, characterized in that: The device comprises: A partition key value acquisition module is used to obtain the target partition key value; A partition interval module, used to obtain the current database partition and the partition interval of the current database partition; wherein the partition interval includes the partition start position and the partition end position of each current database partition; A position identification module, used to identify the position of the target partition key value according to the partition start position and the partition end position, so as to obtain the partition key value position; A target partition position acquisition module, used to determine a target partition start position and a target partition end position based on a preset dynamic partition step, the partition start position, the partition end position and the partition key value position; A position loop traversal module, used for performing a position loop traversal on the target partition key value between the target partition start position and the target partition end position according to the partition key value position, to obtain a traversal key value position; The partition creation module is used to create a partition for the target partition key value according to the traversal key value position, the target partition starting position and the target partition ending position to obtain a target database partition.

9. An electronic device, characterized in that: The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the database partitioning method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the database partitioning method according to any one of claims 1 to 7 is implemented.