Method and apparatus for time-based library and table splitting

By dynamically generating table structures, the problem of high configuration complexity in database sharding and table partitioning in existing technologies is solved, achieving storage space saving and improved operational efficiency.

CN114443650BActive Publication Date: 2026-02-13AISINO SOFTWARE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111665197.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-31
Publication Date
2026-02-13
Estimated Expiration
2041-12-31

AI Technical Summary

Technical Problem

Existing technologies struggle to reduce configuration complexity and effectively improve efficiency when faced with a large number of write requests.

Method used

The method of dynamically generating table structures is adopted, and table structures are only created when needed. The database operation request information is obtained to determine whether a new table structure needs to be created, and the corresponding operations are performed in the newly created table structure. Other operations are handled using a pre-created empty table structure.

Benefits of technology

It reduces storage space waste and management complexity, saves costs, and improves the processing efficiency of database operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114443650B_ABST
    Figure CN114443650B_ABST
Patent Text Reader

Abstract

The present disclosure provides a method and device for time-based library and table separation, the method comprising: obtaining request information for a database operation; the request information being used for at least one of an increase operation, a lookup operation, a delete or modify operation, or a rewrite operation on the database; when the request information is used to represent an increase operation, determining whether a corresponding table structure has been established; when it is determined that there is no corresponding table structure, newly creating a corresponding table structure and performing the increase operation in the newly created corresponding table structure; and when it is determined that the corresponding table structure has been established, performing the increase operation in the established corresponding table structure. According to the present disclosure, the corresponding table structure is dynamically generated only when the request information is used to represent the increase operation, which greatly facilitates the storage and management mechanism, saves costs, reduces configuration complexity, and improves efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of database, in particular to a method and device for database and table splitting according to time. BACKGROUND

[0002] In the past, only single database is enough, then more and more requests are faced, write and read operations of the database are separated, multiple slave replication is used for reading, master is used for writing, slave synchronizes data with master to keep data consistency. The architecture is database master-slave synchronization. Slave can be horizontally expanded, so more read requests are not a problem. However, when the user level comes, more and more write requests are needed. Adding a master cannot solve the problem, because data consistency needs to be saved, and write operation needs to be synchronized between two masters, which is equivalent to repeating and more complex.

[0003] With the development of business data, a single database is increasingly difficult to support large data volume, and then sharding stands out, such as mycat, sharding-jdbc and other middleware.

[0004] The existing patent with publication number CN105488050A and name of a method and system for database and table splitting according to time discloses a database multi-index method, device and system. By establishing an associated index table, the corresponding relationship between the new index key and the primary index key is stored in the associated index table. When the new index key is used as the primary index key for query, the corresponding primary index key is found in the associated index table according to the new index key, and the corresponding primary index key is routed to the database and table splitting to complete the data query. By using the associated index table to replace the new index key for database and table splitting, it avoids recording one or more data, greatly reduces the data size and workload. The patent mainly focuses on the nodes of database and table splitting, does not consider the generation mechanism of database and table splitting, cannot reduce the configuration complexity, and is difficult to improve the efficiency. SUMMARY

[0005] Therefore, the purpose of the embodiments of the present application is to provide a method and device for database and table splitting according to time, which can reduce the configuration complexity and improve the efficiency.

[0006] According to an embodiment of the present disclosure, a control method of a wind turbine generator system is provided, which includes: obtaining request information of a database operation; the request information is used for at least one of an adding operation, a searching operation, a deleting and modifying operation or a rewriting operation on the database; when the request information is used for representing the adding operation, judging whether a corresponding table structure has been established; when it is determined that the corresponding table structure has not been established, newly creating the corresponding table structure and performing the adding operation in the newly created corresponding table structure; and when it is determined that the corresponding table structure has been established, performing the adding operation in the already established corresponding table structure.

[0007] Further, after the step of obtaining the request information of the database operation, the method further includes: when the request information is used for representing the searching operation, the deleting and modifying operation or the rewriting operation, performing the searching operation, the deleting and modifying operation or the rewriting operation corresponding to the request information by using a pre-established empty table structure.

[0008] Further, the method of dividing the database and the table according to time further includes: the empty table structure is established when a database service is started.

[0009] Further, after the step of newly creating the corresponding table structure, the method further includes: updating a configuration file of the database.

[0010] According to another embodiment of the present disclosure, a device of dividing the database and the table according to time is provided, which includes:

[0011] An obtaining unit is configured to obtain request information of a database operation; the request information is used for at least one of an adding operation, a searching operation, a deleting and modifying operation or a rewriting operation on the database;

[0012] A judging unit is configured to, when the request information is used for representing the adding operation, judge whether a corresponding table structure has been established;

[0013] A processing unit is configured to, when it is determined that the corresponding table structure has not been established, newly create the corresponding table structure and perform the adding operation in the newly created corresponding table structure; or, when it is determined that the corresponding table structure has been established, perform the adding operation in the already established corresponding table structure.

[0014] Further, the processing unit is further configured to, when the request information is used for representing the searching operation, the deleting and modifying operation or the rewriting operation, perform the searching operation, the deleting and modifying operation or the rewriting operation corresponding to the request information by using a pre-established empty table structure.

[0015] Further, the device of dividing the database and the table according to time further includes: the empty table structure is established when a database service is started.

[0016] Further, the device for dividing database and table according to time further comprises an updating unit configured to update the configuration file of the database after the processing unit newly creates the corresponding table structure.

[0017] According to an embodiment of the present disclosure, a computer readable storage medium storing a computer program is provided, when the computer program is executed by a processor, the method as described above is implemented.

[0018] According to an embodiment of the present disclosure, a computing device is provided, comprising: a processor; a memory storing a computer program, when the computer program is executed by the processor, the control method as described above is implemented.

[0019] By using the method and device for dividing database and table according to time according to the embodiments of the present disclosure, compared with the previous scheme that mostly generates tables in advance and wastes storage space, the method and device greatly facilitate the storage and management mechanism, save costs, reduce configuration complexity, and improve efficiency. BRIEF DESCRIPTION OF DRAWINGS

[0020] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor on the basis of these drawings.

[0021] Figure 1 is a flow chart of the method for dividing database and table according to time according to the embodiment one of the present disclosure.

[0022] Figure 2 is a flow chart of the method for dividing database and table according to time according to the embodiment two of the present disclosure.

[0023] Figure 3 is a structural schematic diagram of the device for dividing database and table according to time according to the embodiment three of the present disclosure. DETAILED DESCRIPTION

[0024] The embodiments of the present application will be described in detail below with reference to the drawings.

[0025] It should be noted that, in the case of no conflict, the following embodiments and the features in the embodiments can be combined with each other; and based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present disclosure.

[0026] It is noted that various aspects of the embodiments within the scope of the appended claims are described hereinafter. It is to be understood that the aspects described herein can be implemented in widely varying forms and that any particular structure and / or function described herein is merely illustrative. Based on the disclosure provided, one skilled in the art should appreciate that an aspect described herein can be implemented independent of any other aspects, and that two or more of these aspects can be combined in any suitable manner. For example, an apparatus can be implemented and / or a method can be practiced using any number of the aspects set forth herein. In addition, such an apparatus can be implemented and / or such a method can be practiced using other structure and / or functionality in addition to or other than one or more of the aspects set forth herein.

[0027] Figure 1 is a flowchart of a method of time-based database and table partitioning according to an embodiment of the present disclosure. As shown in Figure 1

[0028] Step S101, obtaining request information for database operation; the request information is used for at least one of an increase operation, a lookup operation, a deletion and modification operation, or a rewrite operation on the database.

[0029] Step S102, when the request information is used to represent the increase operation, judging whether the corresponding table structure has been established.

[0030] Step S103, when it is determined that there is no corresponding table structure, newly creating the corresponding table structure, and executing the increase operation in the newly created corresponding table structure.

[0031] Step S104, when it is determined that the corresponding table structure has been established, executing the increase operation in the already established corresponding table structure.

[0032] The embodiment dynamically generates the corresponding table structure when the request information for database operation is used to represent the increase operation and it is determined that there is no corresponding table structure, and executes the increase operation in the newly created corresponding table structure, compared with the previous scheme which mostly generates the table in advance, wasting the storage space, greatly facilitating the storage and management mechanism, saving the cost, reducing the configuration complexity, and improving the efficiency.

[0033] Figure 2 is a flowchart of a method of time-based database and table partitioning according to an embodiment of the present disclosure. Figure 2 is Figure 1 the preferred implementation of the embodiment shown as Figure 2 , specifically includes:

[0034] Step 201, first obtaining request information for database operation.

[0035] Step 202, judging whether the request information is used to represent the increase operation.​

[0036] Step 203, when the request information is used to represent an increase operation, determining whether a corresponding table structure has been established.

[0037] Step 204, when it is determined that no corresponding table structure has been established, newly establishing a corresponding table structure, updating a configuration file of the database, and performing the increase operation in the newly established corresponding table structure.

[0038] Step 205, when it is determined that a corresponding table structure has been established, performing the increase operation in the already established corresponding table structure.

[0039] Step 206, when the request information is used to represent a search operation, a delete / modify operation, or a rewrite operation, performing the search operation, the delete / modify operation, or the rewrite operation corresponding to the request information by using a pre-established empty table structure. In a specific operation, the empty table structure is established when the database service is started.

[0040] That is, an empty table is first set in the database, and no write operation is performed. As time goes by, when a write operation is found at a certain time, a table is generated according to the current time, and then the cache is updated. At this time, the service considers that the table exists.

[0041] The embodiment increases a capacity expansion mechanism loaded on demand on the basis of sharding-jdbc. Only when an increase operation (an insert operation) is performed on the database, a table is dynamically generated, and a table structure is created on demand. That is, a large table is used when the business volume is large, and a table is not created when there is no access. As much as used, as much as generated. For a query, deletion, and change, a default empty table is provided, which greatly facilitates storage and management mechanisms. Because there is an empty table, any search, deletion, and modification that is not in the time interval will not be affected, and the processing efficiency of the query, deletion, and change will not be reduced.

[0042] Figure 3 is a block diagram of a device for sharding a database and a table according to time according to an embodiment of the present disclosure. As shown in Figure 3 the device for sharding a database and a table according to time can include:

[0043] An acquisition unit 301 is configured to acquire request information of a database operation. The request information is used for at least one of an increase operation, a search operation, a delete / modify operation, or a rewrite operation on a database.

[0044] A determination unit 302 is configured to determine whether a corresponding table structure has been established when the request information is used to represent an increase operation.

[0045] The processing unit 303 is configured to, when it is determined that the corresponding table structure does not exist, newly build the corresponding table structure and perform the adding operation in the newly built corresponding table structure; or when it is determined that the corresponding table structure has been built, perform the adding operation in the already built corresponding table structure.

[0046] Preferably, the processing unit 303 is further configured to, when the request information is used to represent a lookup operation, a delete / modify operation or a rewrite operation, perform the lookup operation, the delete / modify operation or the rewrite operation corresponding to the request information by using the pre-built empty table structure.

[0047] Preferably, the device for sharding a database and tables according to time further comprises that the empty table structure is built when the database service is started.

[0048] Preferably, the device for sharding a database and tables according to time further comprises an updating unit 304 configured to update a configuration file of the database after the processing unit newly builds the corresponding table structure.

[0049] The embodiment increases a capacity expansion mechanism on demand on the basis of sharding-jdbc, and only when an adding operation (an insert operation) is performed on the database, a table is dynamically generated, a table structure is created on demand, that is, a large table is large, and a table that is not accessed is not created, and as many tables as used are generated; for a query, deletion and modification, a default empty table is provided, which greatly facilitates a storage and management mechanism, because there is an empty table, any query, deletion and modification that is not in the time interval will not be affected, and the processing efficiency of the query, deletion and modification will not be reduced.

[0050] The application further provides a computer readable storage medium, wherein the storage medium stores a computer program, and the program is executed by a processor to implement the steps of the method for sharding a database and tables according to time.

[0051] The application further provides a computer device, which comprises a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the method for sharding a database and tables according to time when executing the program.

[0052] The medium and the computer device have the corresponding technical effects of the method for sharding a database and tables according to time.

[0053] The above merely describes specific embodiments of the application, but the protection scope of the application is not limited thereto, and any person skilled in the art can easily think of changes or replacements within the technical range disclosed by the application, which should be covered in the protection scope of the application. Therefore, the protection scope of the application should be subject to the protection scope of the claims.

Claims

1. A method of time-bank and time-table division, characterized in that, The method comprises the following steps: obtaining request information for database operation; the request information is used for at least one of an adding operation, a searching operation, a deleting and modifying operation or a rewriting operation on the database; when the request information is used for representing the adding operation, judging whether a corresponding table structure has been established; when it is determined that no corresponding table structure exists, dynamically creating a corresponding table structure, updating a configuration file of the database, and executing the adding operation in the newly created corresponding table structure; when it is determined that the corresponding table structure has been established, executing the adding operation in the already established corresponding table structure; further comprising, before obtaining the request information for database operation, setting an empty table in the database and not performing any write operation.

2. The method of time-based library and table partitioning of claim 1, wherein, The method further comprises the following steps after the step of obtaining the request information for database operation: when the request information is used for representing the searching operation, the deleting and modifying operation or the rewriting operation, using a pre-established empty table structure to perform the corresponding searching operation, the deleting and modifying operation or the rewriting operation of the request information.

3. The method of time-division library partitioning of claim 2, wherein, The method further comprises the following steps: the empty table structure is established when the database service is started.

4. An apparatus for time library partitioning, characterized by, The method comprises the following steps: an obtaining unit is configured to obtain request information for database operation; the request information is used for at least one of an adding operation, a searching operation, a deleting and modifying operation or a rewriting operation on the database; a judging unit is configured to, when the request information is used for representing the adding operation, judge whether a corresponding table structure has been established; a processing unit is configured to, when it is determined that no corresponding table structure exists, dynamically create a corresponding table structure and execute the adding operation in the newly created corresponding table structure; or execute the adding operation in the already established corresponding table structure when it is determined that the corresponding table structure has been established; an updating unit is configured to update a configuration file of the database after the processing unit creates the corresponding table structure; the method further comprises, before obtaining the request information for database operation, setting an empty table in the database and not performing any write operation. The processing unit is further configured to, when the request information is used for representing the searching operation, the deleting and modifying operation or the rewriting operation, use a pre-established empty table structure to perform the corresponding searching operation, the deleting and modifying operation or the rewriting operation of the request information.

5. The time-division library table division apparatus according to claim 4, wherein The method further comprises the following steps:

6. The time-base and table-base separating device according to claim 5, wherein the empty table structure is established when the database service is started. The computer device comprises a processor and a memory:

7. A computer device, characterized by the memory is configured to store program code and transmit the program code to the processor; the processor is configured to execute the method according to any one of claims 1-3 according to instructions in the program code. The computer readable storage medium is configured to store program code, and the program code is used to execute the method according to any one of claims 1-3.

8. A computer-readable storage medium, characterized in that, ​

Citation Information

Patent Citations

  • Database multi-index method, apparatus and system

    CN105488050A

  • Database partitioning and table partitioning method and device, medium and computer equipment

    CN111339088A