Database updating method and device

By pre-sorting incremental data and updating the index table in an orderly manner, the problems of cumbersome operations and low efficiency in the data insertion process are solved, and efficient data insertion and index maintenance are achieved.

CN116521667BActive Publication Date: 2026-06-05中国移动通信集团云南有限公司 +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
中国移动通信集团云南有限公司
Filing Date
2022-01-20
Publication Date
2026-06-05

Smart Images

  • Figure CN116521667B_ABST
    Figure CN116521667B_ABST
Patent Text Reader

Abstract

The application relates to the field of databases, in particular to a database updating method and device. The method comprises the following steps: sorting each incremental data in a first table according to the data type and data size of the incremental data, wherein each incremental data of the same type is arranged in descending order of data size, and each type of incremental data is arranged in descending order of total data size; storing each incremental data in the first table in the storage space of a database according to the arrangement order, and updating an index table of the database according to the type, data size and storage position of each incremental data. The database updating method provided by the embodiment can process data in descending order of data size, and can improve the data insertion efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of databases, and more particularly to a database update method and apparatus. Background Technology

[0002] Creating indexes for a database can improve retrieval speed. However, indexes also need to be maintained when new data is inserted into the database.

[0003] The existing technologies fail to provide an orderly processing method for inserting new data into the database and maintaining indexes. Because large datasets are prone to processing errors during database writing and index maintenance, prioritizing smaller datasets and then attempting to process larger datasets later with errors necessitates reviewing or rolling back previously successfully inserted data. This method is cumbersome and inefficient. Summary of the Invention

[0004] In view of this, embodiments of the present invention provide a database update method and apparatus that process data in descending order of data volume, thereby improving data insertion efficiency.

[0005] In a first aspect, embodiments of the present invention provide a database update method, including:

[0006] Based on the data type and data volume of each incremental data, the incremental data are sorted in the first table. Incremental data belonging to the same type are arranged in descending order of data volume, and incremental data of different types are arranged in descending order of total data volume.

[0007] Each incremental data in the first table is stored in the database storage space one by one in the sorted order, and the database index table is updated according to the type, size and storage location of each incremental data.

[0008] In one possible implementation, the index table includes multiple index entries, each index entry being associated with a single data entry in the storage space of the database. Each index entry includes the data type, data size, and storage location. Index entries with the same data type are arranged in descending order of data size, while index entries with different data types are arranged in descending order of total data size.

[0009] In one possible implementation, each piece of incremental data includes a data type field and a data volume field. The data type field indicates the business type of the incremental data, and the data volume field indicates the storage space occupied by the incremental data.

[0010] One possible implementation involves updating the database index table based on the type, size, and storage location of each incremental data entry, including:

[0011] Determine the target region in the index table where the index entry that matches the incremental data type is located;

[0012] The target position is determined based on the data volume of each index item in the target area. The data volume of the index item before the target position is greater than or equal to the incremental data, and the data volume of the index item after the target position is less than or equal to the incremental data.

[0013] Add an index entry for the incremental data at the target location.

[0014] One possible implementation involves storing each incremental data point in the first table sequentially into the database's storage space, and updating the database's index table based on the type, size, and storage location of each incremental data point. The implementation further includes:

[0015] Determine the total data volume of each type of index item in the index table;

[0016] The index entries of different data types in the index table are reordered in descending order of total data volume.

[0017] Secondly, an embodiment of the present invention provides a database update apparatus, comprising:

[0018] The pre-sorting module is used to sort the incremental data in the first table according to the data type and data volume of each incremental data. Incremental data of the same type are arranged in descending order of data volume, and incremental data of different types are arranged in descending order of total data volume.

[0019] The database update module is used to store each incremental data in the first table into the database storage space one by one in the sorted order, and update the database index table according to the type, data size and storage location of each incremental data.

[0020] In one possible implementation, the database update module further includes:

[0021] An index table adding submodule is used to determine the target region where the index item with the same data type as the incremental data is located in the index table; determine the target position according to the data size of each index item in the target region, wherein the data size of the index item before the target position is greater than or equal to the incremental data, and the data size of the index item after the target position is less than or equal to the incremental data; and add the index item of the incremental data at the target position.

[0022] In one possible implementation, the database update module further includes:

[0023] The index table sorting submodule is used to store each incremental data in the first table into the database storage space one by one according to the sorting order, and after updating the database index table according to the type, data size and storage location of each incremental data, determine the total data volume of each type of index item in the index table; and re-sort the index items of different data types in the index table according to the order of total data volume from largest to smallest.

[0024] Thirdly, embodiments of the present invention provide an electronic device, comprising:

[0025] At least one processor; and

[0026] At least one memory communicatively connected to the processor, wherein:

[0027] The memory stores program instructions that can be executed by the processor, and the processor can execute the method provided in the first aspect by calling the program instructions.

[0028] Fourthly, embodiments of the present invention provide a computer-readable storage medium comprising a stored program, wherein the program, when executed, controls the device containing the computer-readable storage medium to perform the method described in the first aspect.

[0029] It should be understood that the second to fourth aspects of the embodiments of the present invention are consistent with the technical solutions of the first aspect of the embodiments of the present invention, and the beneficial effects achieved by each aspect and the corresponding feasible implementation are similar, and will not be described again.

[0030] The database update method and apparatus provided in the embodiments of the invention process data in descending order of data volume, which can improve data insertion efficiency. Attached Figure Description

[0031] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0032] Figure 1 A flowchart of a database update method provided in an embodiment of the present invention;

[0033] Figure 2 A database processing flowchart provided for an embodiment of the present invention;

[0034] Figure 3 A schematic diagram of a database update device provided in an embodiment of the present invention;

[0035] Figure 4 A schematic diagram of another database update device provided in an embodiment of the present invention;

[0036] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0037] To better understand the technical solution of the present invention, the embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0038] It should be understood that the described embodiments are merely some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.

[0039] The terminology used in the embodiments of this invention is for the purpose of describing particular embodiments only and is not intended to limit the invention. The singular forms “a,” “the,” and “the” as used in the embodiments of this invention and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise.

[0040] Existing technologies fail to provide a method for orderly data insertion and index maintenance, resulting in cumbersome operations and low processing efficiency. This invention provides a database update method that processes data in descending order of volume, thereby improving data insertion efficiency.

[0041] Figure 1 This is a flowchart illustrating a database update method provided in an embodiment of the present invention. Figure 1 As shown, the above database update method may include:

[0042] Step 101: Sort each incremental data in the first table according to the data type and data volume of each incremental data. Incremental data of the same type are arranged in descending order of data volume, and incremental data of different types are arranged in descending order of total data volume.

[0043] Incremental data refers to data to be inserted into the database. When performing this step, the data type and size of each incremental data entry can be determined first. Preferably, a data type field and a data size field can be added to each incremental data entry.

[0044] The data volume field indicates the amount of storage space required for the incremental data; the data type field indicates the business type of the incremental data. For example, incremental data can be categorized into billing, accounting, and user information types, and an identifier can be assigned to each business type, which will then be used as the value of the data type field.

[0045] After determining the data type and size of each incremental data entry, a blank table can be created, referred to as the first table. Then, all incremental data is stored in the first table and sorted according to their type and size. During sorting, incremental data entries of the same type are arranged in descending order of size, while incremental data entries of different types are arranged in descending order of total size. The total size is the sum of the sizes of all incremental data entries of the same type.

[0046] In a specific example, suppose there are a total of 5 incremental data entries, namely:

[0047] Data 100, type A, data quantity 6; Data 161, type B, data quantity 3; Data 109, type B, data quantity 6; Data 136, type C, data quantity 6; Data 115, type A, data quantity 6.

[0048] The first table corresponding to the above 5 incremental data points is shown in Table 1:

[0049]

[0050] Table 1 Example of the first table

[0051] The above 5 incremental data entries are divided into 3 types. The total data volume of type A is the sum of the data volumes of data 100 and data 115, which is 11; the total data volume of type B is the sum of the data volumes of data 161 and data 109, which is 9; and the total data volume of type C is 6. In order of decreasing total data volume, the incremental data of type A is first in the first table, the incremental data of type B is in the middle, and the incremental data of type C is last.

[0052] Meanwhile, both type A and type B contain two incremental data points. In data points 100 and 115, which belong to type A, data 100 is ranked before data 115 because its data volume is greater. Similarly, in data points 109 and 161, which belong to type B, data 109 is ranked before data 161 because its data volume is greater.

[0053] After storing the incremental data in the first table and sorting the incremental data in the first table according to the above method, continue to execute step 102.

[0054] Step 102: Store each incremental data in the first table into the database storage space one by one in the order of arrangement, and update the database index table according to the type, size and storage location of each incremental data.

[0055] Specifically, a database index table contains multiple index entries, each associated with a single record in the database's storage space. Each index entry includes at least the data type, data size, and storage location of the corresponding data. Furthermore, index entries of the same type are arranged in descending order of data size, while index entries of different types are arranged in descending order of total data size.

[0056] In this step, each incremental data in the first table can be identified as data to be processed in the order of arrangement. After the data to be processed is successfully inserted into the storage space of the database and the index item of the data to be processed is successfully added to the index table, the next incremental data can be identified as data to be processed.

[0057] When updating the index table for data to be processed, first determine the target area in the index table where the index entries with the same data type as the data to be processed are located. Then, determine the target position based on the data size of each index entry in the target area. The data size of the index entries before the target position is greater than or equal to the data to be processed, and the data size of the index entries after the target position is less than or equal to the data to be processed. Add the index entry for the data to be processed at the target position. The index entry for the data to be processed must include at least a data type field, a data size field, and a storage location field. The storage location refers to the position of the data to be processed in the database's storage space.

[0058] In a specific example, assuming the incremental data in the first table is as shown in Table 1, and the database index table is as shown in Table 2 before performing this step:

[0059]

[0060] Table 2 Index Representation Example 1

[0061] First, identify data 100 as the data to be processed. At this point, the area where the index entry of type A in the index table is located can be identified as the target area (i.e., the area where the index entries corresponding to data 1, data 5, data 31, and data 86 are located). Based on the amount of data 100, the target position can be determined to be after data 86, and an index entry for data 100 can be added at the target position.

[0062] After successfully adding the index entry for data 100, data 115 is identified as the data to be processed. Since data 115 has the same data type as data 100 and its data volume is smaller than that of data 100, the target location can be found directly in the target area after the index entry for data 100, without considering the target area before the index entry for data 100.

[0063] Following the method described above, data 109, 161, and 136 were identified as data to be processed, and the operations of inserting the data into the database and adding index entries were performed. After completing the task of adding index entries for each incremental data item shown in Table 1, the index table can be as shown in Table 3:

[0064]

[0065] Table 3 Index Representation Example 2

[0066] After adding incremental data to the index entries in the index table, the ranking of the total data volume of each type of index entry may change. Therefore, after completing the above steps, it is necessary to separately calculate the total data volume of each type of index entry in the table, and then reorder the different types of index entries in the index table according to the order of total data volume from largest to smallest. It should be noted that during the reordering process, the order of index entries of the same type remains unchanged.

[0067] Figure 2 This illustrates a database processing flow. For example... Figure 2 As shown, users can insert data into the first table via SQL requests; they can also query data in the first table via SQL requests, and the first table can return the query results.

[0068] Figure 2 The processing flow shown is the process of reading incremental data from the first table in sorted order, writing the incremental data into the database storage space, and adding an index entry for the incremental data to the index table. Specifically, "data retrieval" refers to reading incremental data from the first table in sorted order; "data insertion" between the processing flow, the database storage space, and the index table refers to writing the incremental data into the database and adding an index entry for the incremental data to the index table; the database storage space and index table can return results indicating success or failure; the processing flow can delete successfully processed incremental data from the first table to prevent it from interfering with subsequent processing steps, such as the processing flow mistakenly using successfully processed incremental data as pending incremental data; the first table can return a result indicating whether the incremental data deletion was successful or failed to the processing flow.

[0069] In addition, users can also use SQL statements to query data in the database's storage space and index tables, and receive the query results.

[0070] The database update method provided in this invention offers an ordered data processing flow, employing a first table as a buffer to improve the efficiency of incremental data insertion. Simultaneously, it prioritizes processing incremental data with larger volumes, which on the one hand avoids excessive invalid processing and reduces the impact of processing failures, and on the other hand saves system processing resources.

[0071] Figure 3 This is a schematic diagram of a database update device provided in an embodiment of the present invention. Figure 3 As shown, the above-mentioned device may include:

[0072] The pre-sorting module 31 is used to sort the incremental data in the first table according to the data type and data volume of each incremental data, wherein the incremental data of the same type are arranged in descending order of data volume, and the incremental data of each type are arranged in descending order of total data volume.

[0073] The database update module 32 is used to store each incremental data in the first table into the storage space of the database one by one in the order of arrangement, and update the index table of the database according to the type, data size and storage location of each incremental data.

[0074] Figure 3 The database update apparatus provided in the illustrated embodiment can be used to execute the present invention. Figure 1 The implementation principle and technical effects of the method embodiment shown can be further referred to the relevant description in the method embodiment.

[0075] Figure 4 This is a schematic diagram of another database update device provided in an embodiment of the present invention. Figure 4 As shown, the database update module 32 may further include:

[0076] The index table adding submodule 41 is used to determine the target area where the index item with the same data type as the incremental data is located in the index table; determine the target position according to the data size of each index item in the target area, wherein the data size of the index item before the target position is greater than or equal to the incremental data, and the data size of the index item after the target position is less than or equal to the incremental data; and add the index item of the incremental data at the target position.

[0077] The index table sorting submodule 42 is used to store each incremental data in the first table into the storage space of the database one by one according to the sorting order, and after updating the index table of the database according to the type, data size and storage location of each incremental data, determine the total data volume of each type of index item in the index table; and re-sort the index items of different data types in the index table according to the order of total data volume from largest to smallest.

[0078] Figure 5 A schematic diagram of the structure of an electronic device provided for the implementation of the present invention. Figure 5 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of the present invention.

[0079] like Figure 5 As shown, the electronic device may include at least one processor; and at least one memory communicatively connected to the processor, wherein the memory stores program instructions executable by the processor, and the processor can execute the present invention by calling the program instructions. Figure 1 The illustrated embodiment provides a database update method. The electronic device is manifested as a general-purpose computing device. The components of the electronic device may include, but are not limited to: one or more processors 410, a communication interface 420, a memory 430, and a communication bus 440 connecting different system components (including the memory 430 and the processor 410).

[0080] Communication bus 440 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. For example, these architectures include, but are not limited to, Industry Standard Architecture (ISA) buses, Micro Channel Architecture (MAC) buses, Enhanced ISA buses, Video Electronics Standards Association (VESA) local buses, and Peripheral Component Interconnect (PCI) buses.

[0081] Electronic devices typically include a variety of computer-readable media. These media can be any available media that can be accessed by the electronic device, including volatile and non-volatile media, and removable and non-removable media.

[0082] Memory 430 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) and / or cache memory. The electronic device may further include other removable / non-removable, volatile / non-volatile computer system storage media. Memory 430 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of the present invention.

[0083] A program / utility having a set (at least one) of program modules can be stored in memory 430. Such program modules include—but are not limited to—an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. The program modules typically perform the functions and / or methods described in the embodiments of the present invention.

[0084] Processor 410 executes various functional applications and data processing by running programs stored in memory 430, such as implementing the present invention. Figure 1 The database update method provided in the illustrated embodiment.

[0085] This invention provides a computer-readable storage medium comprising a stored program, wherein the program, when executed, controls the device containing the computer-readable storage medium to perform the invention. Figure 1 The database update method provided in the illustrated embodiment.

[0086] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including—but not limited to—electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of transmitting, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.

[0087] The program code contained on a computer-readable medium may be transmitted using any suitable medium, including—but not limited to—wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.

[0088] Computer program code for performing the operations of this invention can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN), or it can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0089] The foregoing has described specific embodiments of the invention. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired results. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0090] In the description of this invention, the terms "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of the invention. In this invention, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in a suitable manner in any one or more embodiments or examples. Moreover, those skilled in the art can combine and integrate the different embodiments or examples described in this invention, as well as the features of different embodiments or examples, without contradiction.

[0091] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this invention, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0092] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing custom logic functions or processes, and the scope of preferred embodiments of the invention includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of the invention pertain.

[0093] Depending on the context, the word "if" as used here can be interpreted as "when," "when," "in response to determination," or "in response to detection." Similarly, depending on the context, the phrase "if determination" or "if detection (of the stated condition or event)" can be interpreted as "when determination," "in response to determination," "when detection (of the stated condition or event)," or "in response to detection (of the stated condition or event)."

[0094] In the embodiments provided by this invention, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0095] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in the form of hardware plus software functional units.

[0096] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A database update method, characterized in that, include: Based on the data type and data volume of each incremental data, the incremental data are sorted in the first table. Incremental data belonging to the same type are arranged in descending order of data volume, and incremental data of different types are arranged in descending order of total data volume. Each incremental data in the first table is stored in the database storage space one by one in the order of arrangement, and the database index table is updated according to the type, size and storage location of each incremental data. The index table includes multiple index entries, each index entry is associated with a data entry in the database storage space, and each index entry includes the type, size and storage location of the corresponding data. Index entries with the same data type are arranged in descending order of data size, and index entries with different data types are arranged in descending order of total data size. Update the database index tables based on the type, size, and storage location of each incremental data entry, including: Determine the target region in the index table where the index entry that matches the incremental data type is located; The target position is determined based on the data volume of each index item in the target area. The data volume of the index item before the target position is greater than or equal to the incremental data, and the data volume of the index item after the target position is less than or equal to the incremental data. Add an index entry for the incremental data at the target location.

2. The method according to claim 1, characterized in that, Each piece of incremental data includes a data type field and a data volume field. The data type field indicates the business type of the incremental data, and the data volume field indicates the storage space occupied by the incremental data.

3. The method according to claim 1, characterized in that, After storing each incremental data in the first table into the database storage space in order of arrangement, and updating the database index table according to the type, size, and storage location of each incremental data, the process also includes: Determine the total data volume of each type of index item in the index table; The index entries of different data types in the index table are reordered in descending order of total data volume.

4. A database update device, characterized in that, include: The pre-sorting module is used to sort the incremental data in the first table according to the data type and data volume of each incremental data. Incremental data of the same type are arranged in descending order of data volume, and incremental data of different types are arranged in descending order of total data volume. The database update module is used to store each incremental data in the first table into the database storage space one by one in the sorted order, and update the database index table according to the type, data size and storage location of each incremental data. The database update module also includes: An index table adding submodule is used to determine the target region where the index item with the same data type as the incremental data is located in the index table; determine the target position according to the data size of each index item in the target region, wherein the data size of the index item before the target position is greater than or equal to the incremental data, and the data size of the index item after the target position is less than or equal to the incremental data; and add the index item of the incremental data at the target position.

5. The apparatus according to claim 4, characterized in that, The database update module also includes: The index table sorting submodule is used to store each incremental data in the first table into the database storage space one by one according to the sorting order, and after updating the database index table according to the type, data size and storage location of each incremental data, determine the total data volume of each type of index item in the index table; and re-sort the index items of different data types in the index table according to the order of total data volume from largest to smallest.

6. An electronic device, characterized in that, include: At least one processor; as well as At least one memory communicatively connected to the processor, wherein: The memory stores program instructions that can be executed by the processor, and the processor can execute the method as described in any one of claims 1 to 3 by calling the program instructions.

7. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein, when the program is executed, it controls the device on which the computer-readable storage medium is located to perform the method of any one of claims 1 to 3.