Data storage method, device, equipment, storage medium and program product
By sorting and rewriting data values in the database during the low access period, the LSMT structure's shortcomings in range query performance are solved, query efficiency is improved and data integrity is ensured.
Patent Information
- Application Number
- CN202410344688.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-25
- Publication Date
- 2025-06-17
- Estimated Expiration
- 2044-03-25
AI Technical Summary
The LSMT structure designed with key-value separation has shortcomings in scope query performance.
During the time period when the data access is small, the data values to be sorted in the target database are read, sorted and rewrite to the database, thereby ensuring the order of the data values and improving the range query performance.
By reading, sorting and rewriting data values during low access periods, the database range query performance is improved, and the read and write pressure on the database is reduced, ensuring data integrity and reliability.
Smart Images

Figure CN118170763B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of databases, and particularly relates to a data storage method, apparatus, computer device, storage medium, and program product. Background Art
[0002] Digital management will converge a large amount of information data. The database will adopt two LSMT (Log Structured Merge Tree) structures with key-value separation as the storage layer. While retaining the write performance advantage of the LSMT structure, it improves the write amplification problem of the LSMT structure, but there is also a problem of low performance in range queries. Summary of the Invention
[0003] In view of this, the present invention provides a data storage method, apparatus, computer device, storage medium, and program product to solve the problem of low performance in range queries for the LSMT structure with key-value separation design.
[0004] In a first aspect, the present invention provides a data storage method, which includes:
[0005] Obtain the data access volume of the target database within a preset time;
[0006] If the data access volume within the preset time is less than the preset access volume, read the data values to be sorted in the target database to obtain the first data values;
[0007] Sort the first data values to obtain the second data values;
[0008] Store the second data values into the target database and clear the data values to be sorted.
[0009] In this way, the data values in the target database can be read out, sorted, and rewritten during a period with a small data access volume. On the one hand, it ensures that the data values in the target database are all sorted, thereby improving the performance of range queries. On the other hand, since the read and sort operations are performed during a period with a small data access volume, the read and write pressure on the target database is also small, and it can avoid to the greatest extent the situation where new data values are written into the target database when the data values are read and sorted, resulting in inconsistent second data values with the data values in the target database, thereby ensuring the integrity and reliability of the data values in the target database.
[0010] In an optional implementation manner, reading the data values to be sorted in the target database to obtain the first data values includes:
[0011] Determine all the data values in the target database as the data values to be sorted;
[0012] Read the data values to be sorted to obtain the first data values.
[0013] In an alternative embodiment, storing the second data value into the target database and clearing the data values to be sorted includes:
[0014] Creating a target storage table according to the historical storage tables included in the target database;
[0015] Storing the second data value into the target storage table;
[0016] Clearing the historical storage table.
[0017] In this way, taking all the data values in the target database as the data values to be sorted and sorting all the data values in the target database can ensure that all the data values in the target database are arranged in order, and when searching the target database, it can be directly searched in order, thereby improving the performance of range query of the target database.
[0018] In an alternative embodiment, reading the data values to be sorted in the target database to obtain the first data value includes:
[0019] Determining the storage table group where the updated data value in the target database is located, and determining the data values in the storage table group where the updated data value is located as the data values to be sorted; the updated data value is the data value that has changed in the target database during the current update period; the current update period is the time period from the historical reading time to the current reading time;
[0020] Reading the data values to be sorted to obtain the first data value.
[0021] In an alternative embodiment, storing the second data value into the target database and clearing the data values to be sorted includes:
[0022] Creating a target storage table group according to the storage table group where the updated data value is located;
[0023] Storing the second data value into the target storage table group;
[0024] Clearing the storage table group where the updated data value is located.
[0025] In this way, the storage tables in the target database are grouped, the data values are sorted separately within each group, and each time only the storage table group where the changed data values are located is read and sorted, reducing the workload of data value sorting and alleviating the read and write pressure on the target database.
[0026] In an alternative embodiment, sorting the first data value to obtain the second data value includes:
[0027] Obtaining the tag information of each data value in the first data value;
[0028] Sort each data value in the first data value based on the tag information to obtain a second data value.
[0029] In this way, sorting the data values according to the tag information can improve the efficiency of data query.
[0030] In a second aspect, the present invention provides a data storage device, which includes:
[0031] A data access volume acquisition module, configured to acquire the data access volume of a target database within a preset time;
[0032] A first data value acquisition module, configured to read the data values to be sorted in the target database to obtain a first data value if the data access volume within the preset time is less than a preset access volume;
[0033] A second data value acquisition module, configured to sort the first data value to obtain a second data value;
[0034] A second data value storage module, configured to store the second data value in the target database and clear the data values to be sorted.
[0035] In a third aspect, the present invention provides a computer device, including: a memory and a processor, which are communicatively connected to each other. The memory stores computer instructions, and the processor executes the computer instructions to execute the data storage method according to the first aspect or any corresponding embodiment thereof.
[0036] In a fourth aspect, the present invention provides a computer-readable storage medium, on which computer instructions are stored, and the computer instructions are used to cause a computer to execute the data storage method according to the first aspect or any corresponding embodiment thereof.
[0037] In a fifth aspect, the present invention provides a computer program product, including computer instructions, and the computer instructions are used to cause a computer to execute the data storage method according to the first aspect or any corresponding embodiment thereof. Description of the Drawings
[0038] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for the description of the specific embodiments or the prior art. Obviously, the following drawings are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0039] Figure 1 It is a flowchart of the data storage method according to an embodiment of the present invention;
[0040] Figure 2 is a schematic flowchart of another data storage method according to an embodiment of the present invention;
[0041] Figure 3 is a schematic flowchart of yet another data storage method according to an embodiment of the present invention;
[0042] Figure 4 is a structural block diagram of a data storage device according to an embodiment of the present invention;
[0043] Figure 5 is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. Detailed implementation manners
[0044] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Apparently, the described embodiments are some but 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 creative efforts shall fall within the protection scope of the present invention.
[0045] Digital management will converge a large amount of information data. The database will adopt two LSMT (Log Structured Merge Tree) structures with key-value separation as the storage layer. While retaining the write performance advantages of the LSMT structure, it improves the write amplification problem of the LSMT structure, but at the same time, there is also a problem of low performance in range queries.
[0046] Based on this, an embodiment of the present invention provides a data storage method. This method obtains the data access volume of the target database within a preset time; if the data access volume within the preset time is less than the preset access volume, it reads the data values to be sorted in the target database to obtain the first data values; sorts the first data values to obtain the second data values; stores the second data values in the target database, and clears the data values to be sorted. In this way, the data values in the target database can be read out, sorted, and rewritten during a period with a small data access volume, ensuring that all the data values in the target database are sorted, thereby improving the performance of range queries.
[0047] According to an embodiment of the present invention, an embodiment of a data storage method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.
[0048] In this embodiment, a data storage method is provided, which can be used in a database. Figure 1 It is a flowchart of the data storage method according to the embodiment of the present invention. As Figure 1 shown, the process includes the following steps:
[0049] Step S101, obtain the data access volume of the target database within a preset time.
[0050] In the embodiment of the present invention, the data access volume refers to the read and write volume of the data in the target database. The data access volume of the target database within a preset time can be the total data read and write volume of the target database within the preset time, or the data access volume per unit time can be used as the calculation standard to calculate the average data access volume within the preset time, thereby measuring the data traffic of the target database.
[0051] Step S102, if the data access volume is less than the preset access volume within the preset time, read the data values to be sorted in the target database to obtain the first data value.
[0052] In the embodiment of the present invention, if the data access volume is less than the preset access volume within the preset time, it indicates that the data read and write volume of the target database remains at a relatively low level within the preset time, and the use of the target database is in a low period. At this time, reading and sorting the data values in the target database will not affect the normal reading and writing of the target database, and the reading and writing pressure on the target database is relatively small. At the same time, there are fewer data write operations on the target database at this time. Reading and sorting the data values in the target database at this time can avoid the situation where new data values are written into the target database when reading and sorting the data values to the greatest extent, ensuring the integrity and reliability of the data values in the target database.
[0053] In the embodiment of the present invention, the data value is the value of the data, which is the value stored separately in the key-value separated LSMT structure. The data value to be sorted is the value of the data in the target database that has not been sorted or needs to be sorted.
[0054] In an alternative embodiment, within a preset time period after the historical reading time, that is, the last preset time period after the data value reading and sorting operation on the target database, even if the data access volume is less than the preset access volume, the data value reading operation will not be performed to avoid resource waste caused by frequent data blocking and sorting operations on the target database.
[0055] Step S103, sort the first data value to obtain the second data value.
[0056] In the embodiment of the present invention, the first data value is sorted and stored again in the obtained order to obtain the second data value.
[0057] In an alternative embodiment, sorting the first data values to obtain second data values may include the following steps:
[0058] Step a1: Obtain the label information of each data value in the first data values.
[0059] In the embodiments of the present invention, the label information is the label id of the data, which can uniquely identify a data.
[0060] Step a2: Sort each data value in the first data values based on the label information to obtain second data values.
[0061] In the embodiments of the present invention, using the label information as a reference for sorting, sort each data value in the first data values in ascending or descending order of the label information to complete the aggregation of the data and obtain second data values. The data values in the second data values are arranged in the order of the label information, so that when searching, it can be searched in the order of the label information arrangement, thereby improving the data query efficiency.
[0062] Step S104: Store the second data values in the target database and clear the data values to be sorted.
[0063] In the embodiments of the present invention, store the sorted second data values in the target database. After the second data values are completely written into the target database, clear the data values to be sorted from the target database, thereby realizing the replacement of the data values to be sorted with the second data values, so that the data values in the target database are sorted. Thus, when searching, it can be directly searched in the sorted order, thereby improving the search efficiency.
[0064] In an alternative embodiment, after step S104, it further includes the step of clearing the second data values from the memory storing them, thereby releasing the memory occupied by this part in the memory.
[0065] In an alternative embodiment, after step S104, it further includes backing up the second data values through cloud storage to achieve redundancy of the data values and avoid data loss when the target database encounters abnormal situations.
[0066] The data storage method provided by the embodiments of the present invention reads out the data values in the target database during a time period with a relatively small data access volume, sorts them, and then rewrites them. On the one hand, it ensures that the data values in the target database are all sorted, thereby improving the performance of range queries. On the other hand, since the reading and sorting operations are performed during a time period with a relatively small data access volume, the read and write pressure on the target database is also relatively small, and it can avoid to the greatest extent the situation where new data values are written into the target database when the data values are read and sorted, resulting in inconsistent second data values with the data values in the target database, thereby ensuring the integrity and reliability of the data values in the target database.
[0067] In this embodiment, a data storage method is provided, which can be used for the above-mentioned database. Figure 2 It is a flowchart of another data storage method according to the embodiments of the present invention, as Figure 2 shown, and this process includes the following steps:
[0068] Step S201, obtain the data access volume of the target database within a preset time. For details, please refer to Figure 1 Step S101 of the shown embodiment, which will not be elaborated here.
[0069] Step S202, if the data access volume within the preset time is less than the preset access volume, then read the data values to be sorted in the target database to obtain the first data value.
[0070] Specifically, step S202 includes:
[0071] Step S2021, determine all the data values in the target database as the data values to be sorted.
[0072] In the embodiments of the present invention, the basis for sorting the data values is the arrangement position of the data value among all the data values. Then, each time the data values in the target database are sorted, all the data values in the target database need to be read, that is, all the data values in the target database are determined as the data values to be sorted.
[0073] Step S2022, read the data values to be sorted to obtain the first data value.
[0074] In the embodiments of the present invention, all the data values in the target database are read out to obtain the first data value. The first data value is actually the same as the data values to be sorted, that is, the data values in the target database, but after being read out, it is stored in the memory for easy sorting operation.
[0075] In an alternative embodiment, the first data value can be stored in the memory corresponding to the target database. At the same time, since the data values in the target database are stored in the form of storage tables, that is, in the form of SST (sorted string table), in order to ensure consistency with the data storage structure in the target database and facilitate rewriting the data values into the target database after sorting, corresponding to the historical storage tables included in the target database, storage tables are created in the memory corresponding to the target database. The storage capacity and quantity of these storage tables are the same as those of the historical storage tables, and then the first data value is written into these storage tables.
[0076] Step S203: Sort the first data value to obtain the second data value. For details, please refer to Figure 1 Step S103 of the embodiment shown, which will not be elaborated here.
[0077] Step S204: Store the second data value into the target database and clear the data value to be sorted.
[0078] Specifically, step S204 includes:
[0079] Step S2041: Create a target storage table according to the historical storage tables included in the target database.
[0080] In the embodiment of the present invention, in order to ensure the consistency of the storage structure of the target database before and after sorting, corresponding to the historical storage tables included in the target database before sorting, a target storage table is created in the target database. The storage capacity and quantity of the target storage table are the same as those of the historical storage tables.
[0081] Step S2042: Store the second data value into the target storage table.
[0082] In the embodiment of the present invention, the second data value that has been sorted in the memory is correspondingly stored into the target storage table. Optionally, if a storage table has been created when storing the first data value in the above step S202, the storage table storing the second data value can be directly used as the target storage table and written into the target database.
[0083] Step S2043: Clear the historical storage table.
[0084] In the embodiment of the present invention, since the second data value has been stored into the target database as a replacement for the original data value in the target database, the original data value is no longer necessary. At this time, clearing the original data value will not affect the data integrity. Therefore, in order to make full use of the storage space of the target database, after storing the second data value into the target database, the historical storage table in the target database is cleared to clear the original data value.
[0085] The data storage method provided by the embodiment of the present invention takes all data values in the target database as the data values to be sorted, and sorts all data values in the target database, which can ensure that all data values in the target database are arranged in order. When querying the target database, it can be directly queried in order, thereby improving the performance of the range query of the target database.
[0086] In this embodiment, a data storage method is provided, which can be used for the above database. Figure 3 It is a flowchart of another data storage method according to the embodiment of the present invention, as Figure 3 shown, and this process includes the following steps:
[0087] Step S301, obtain the data access volume of the target database within a preset time. For details, please refer to Figure 1 step S101 of the embodiment shown here, which will not be elaborated here.
[0088] Step S302, if the data access volume within the preset time is less than the preset access volume, read the data values to be sorted in the target database to obtain the first data value.
[0089] Specifically, step S302 includes:
[0090] Step S3021, determine the storage table group where the updated data value in the target database is located, and determine the data values in the storage table group where the updated data value is located as the data values to be sorted.
[0091] In the embodiment of the present invention, the updated data value is the data value that has changed in the target database during the current update cycle. The current update cycle is the time period from the historical reading time to the current reading time, that is, the time period corresponding to the time from the last reading of the data value in the target database to the current reading of the data value in the target database.
[0092] In the embodiment of the present invention, for the convenience of data management, the data values in the target database can be grouped and managed according to the storage tables they are in, and the data values in each storage table group are sorted separately. Therefore, when reading and sorting the data values in the target database, only the storage table group where the changed data values are located needs to be re-sorted. Since the data values in other storage table groups have not changed, they do not need to be re-sorted. At this time, only the data values in the storage table group where the updated data value is located need to be read and sorted, that is, the data values in the storage table group where the updated data value is located are determined as the data values to be sorted.
[0093] Step S3022, read the data values to be sorted to obtain the first data value.
[0094] In an embodiment of the present invention, data values in the storage table group where the updated data value is located are read out to obtain a first data value.
[0095] In an alternative embodiment, the first data value may be stored in the memory corresponding to the target database. To ensure consistency with the data storage structure in the target database and facilitate rewriting the data value into the target database after sorting, corresponding to the storage table group where the updated data value is located, a storage table and a storage table group are created in the memory corresponding to the target database. The storage capacities and quantities of these storage tables are the same as those of the storage tables in the target database, and the storage tables and storage table groups in the memory are associated with the storage tables and storage table groups in the target database, and the first data value is correspondingly written into these storage tables.
[0096] Step S303: Sort the first data value to obtain a second data value. For details, please refer to Figure 1 Step S103 in the illustrated embodiment, which will not be elaborated here.
[0097] Step S304: Store the second data value into the target database and clear the data value to be sorted.
[0098] Specifically, step S304 includes:
[0099] Step S3041: Create a target storage table group according to the storage table group where the updated data value is located.
[0100] In an embodiment of the present invention, to ensure the consistency of the storage structure of the target database before and after sorting, corresponding to the storage table group where the updated data value is located in the target database before sorting, a target storage table and a target storage table group are created in the target database, and the storage table group where the updated data value is located is associated with the target storage table group to avoid incomplete data caused by clearing the wrong storage table group during subsequent data clearing.
[0101] Step S3042: Store the second data value into the target storage table group.
[0102] In an embodiment of the present invention, the second data value that has been sorted in the memory is correspondingly stored into the target storage table group. Optionally, if a storage table group has been created when storing the first data value in step S302 above, the storage table group storing the second data value can be used as the target storage table group and written into the storage directory where the corresponding storage table group in the target database is located.
[0103] Step S3043: Clear the storage table group where the updated data value is located.
[0104] In the embodiment of the present invention, since the second data value has been stored in the target database as a replacement for the original data value in the target database, the original data value is no longer necessary. At this time, clearing the original data value will not affect the integrity of the data. Therefore, in order to make full use of the storage space of the target database, after storing the second data value in the target database, the storage table group where the updated data value is located is cleared to clear the original data value.
[0105] The data storage method provided by the embodiment of the present invention groups the storage tables in the target database, sorts the data values separately within each group, and only reads and sorts the storage table group where the changed data value is located each time, reducing the workload of sorting the data values, improving the efficiency of sorting the data values, and at the same time reducing the read / write pressure on the target database.
[0106] In this embodiment, a data storage device is further provided. This device is used to implement the above embodiments and preferred implementation manners, and those that have been described will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that can achieve a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.
[0107] This embodiment provides a data storage device, as Figure 4 shown, including:
[0108] A data access volume acquisition module 401, configured to acquire the data access volume of the target database within a preset time;
[0109] A first data value acquisition module 402, configured to read the data value to be sorted in the target database to obtain a first data value if the data access volume within the preset time is less than a preset access volume;
[0110] A second data value acquisition module 403, configured to sort the first data value to obtain a second data value;
[0111] A second data value storage module 404, configured to store the second data value in the target database and clear the data value to be sorted.
[0112] In an alternative embodiment, the first data value acquisition module 402 includes:
[0113] A data value to be sorted determination unit, configured to determine all data values in the target database as data values to be sorted;
[0114] A first data value acquisition unit, configured to read the data value to be sorted to obtain a first data value.
[0115] In an alternative embodiment, the second data value storage module 404 includes:
[0116] A target storage table creation unit, configured to create a target storage table according to the historical storage tables included in the target database;
[0117] A second data value storage unit, configured to store the second data value into the target storage table;
[0118] A historical data clearing unit, configured to clear the historical storage table.
[0119] In an alternative embodiment, the first data value acquisition module 402 includes:
[0120] A data value to be sorted determination unit, further configured to determine the storage table group where the updated data value in the target database is located, and determine the data values in the storage table group where the updated data value is located as the data values to be sorted; the updated data value is the data value that has changed in the target database during the current update period; the current update period is the time period from the historical reading time to the current reading time;
[0121] A first data value acquisition unit, further configured to read the data values to be sorted to obtain the first data value.
[0122] In an alternative embodiment, the second data value storage module 404 includes:
[0123] A target storage table group creation unit, configured to create a target storage table group according to the storage table group where the updated data value is located;
[0124] A second data value storage unit, further configured to store the second data value into the target storage table group;
[0125] A historical data clearing unit, further configured to clear the storage table group where the updated data value is located.
[0126] In an alternative embodiment, the second data value acquisition module 403 includes:
[0127] A tag information acquisition unit, configured to acquire the tag information of each data value in the first data value;
[0128] A second data value acquisition unit, configured to sort each data value in the first data value based on the tag information to obtain the second data value.
[0129] The further function descriptions of the above-mentioned modules and units are the same as those in the corresponding embodiments above, and will not be elaborated here.
[0130] The data storage device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and a memory that execute one or more software or fixed programs, and / or other devices that can provide the above functions.
[0131] An embodiment of the present invention further provides a computer device having the above-mentioned Figure 4 data storage device.
[0132] Please refer to Figure 5 , Figure 5 which is a schematic structural diagram of a computer device provided by an alternative embodiment of the present invention. As shown in Figure 5 , the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including a high-speed interface and a low-speed interface. Each component communicates with each other using different buses and can be installed on a common motherboard or installed in other ways as needed. The processor can process instructions executed within the computer device, including instructions stored in the memory or on the memory to display graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In some alternative embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (such as a server array, a set of blade servers, or a multi-processor system). Figure 5 One processor 10 is taken as an example in
[0133] The processor 10 can be a central processing unit, a network processor, or a combination thereof. Among them, the processor 10 can further include a hardware chip. The above hardware chip can be an application specific integrated circuit, a programmable logic device, or a combination thereof. The above programmable logic device can be a complex programmable logic device, a field programmable gate array, a general array logic, or any combination thereof.
[0134] Among them, the memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0135] The memory 20 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system and application programs required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state storage devices. In some alternative embodiments, the memory 20 may optionally include a memory remotely provided with respect to the processor 10, and these remote memories may be connected to the computer device through 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.
[0136] The memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, a hard disk, or a solid-state drive; the memory 20 may further include a combination of the above types of memory.
[0137] The computer device further includes a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0138] Embodiments of the present invention further provide a computer-readable storage medium. The methods according to the embodiments of the present invention may be implemented in hardware, firmware, or be implemented as computer code that can be recorded on a storage medium, or be implemented as computer code originally stored in a remote storage medium or a non-transitory machine-readable storage medium and to be downloaded through a network and stored in a local storage medium, so that the methods described herein can be stored in such software processes on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium may be a magnetic disk, an optical disc, a read-only memory, a random access memory, a flash memory, a hard disk, or a solid-state drive, etc.; further, the storage medium may further include a combination of the above types of memory. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code, and when the software or computer code is accessed and executed by the computer, the processor, or the hardware, the methods shown in the above embodiments are implemented.
[0139] A part of the present invention can be applied as a computer program product, such as computer program instructions, which, when executed by a computer, can invoke or provide the methods and / or technical solutions according to the present invention through the operations of the computer. Those skilled in the art should understand that the forms of existence of computer program instructions in a computer-readable medium include but are not limited to source files, executable files, installation package files, etc. Correspondingly, the ways for a computer to execute computer program instructions include but are not limited to: the computer directly executes the instructions, or the computer compiles the instructions and then executes the corresponding compiled program, or the computer reads and executes the instructions, or the computer reads and installs the instructions and then executes the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to the computer.
[0140] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations all fall within the scope defined by the appended claims.
Claims
1. A data storage method, characterized in that: The method comprises: Obtain the data access volume of the target database within a preset time; If the data access amount within the preset time is less than the preset access amount, the data value to be sorted in the target database is read to obtain a first data value; the data value to be sorted is the value of the data in the target database that has not been sorted or needs to be sorted; Sorting the first data values to obtain a second data value; the sorting the first data values to obtain the second data value includes: obtaining label information of each data value in the first data values; sorting each data value in the first data values based on the label information to obtain the second data value; The second data value is stored in the target database, and the data value to be sorted is cleared.
2. The method according to claim 1, characterized in that: The step of reading the data value to be sorted in the target database to obtain the first data value includes: Determine all data values in the target database as the data values to be sorted; The data value to be sorted is read to obtain the first data value.
3. The method according to claim 2, characterized in that The storing the second data value into the target database and clearing the data value to be sorted includes: Creating a target storage table according to the historical storage table contained in the target database; storing the second data value in the target storage table; Clear the history storage table.
4. The method according to claim 1, characterized in that The step of reading the data value to be sorted in the target database to obtain the first data value includes: Determine the storage table group where the updated data value in the target database is located, and determine the data value in the storage table group where the updated data value is located as the data value to be sorted; the updated data value is the data value in the target database that has changed in the current update cycle; the current update cycle is the time period from the historical reading time to the current reading time; The data value to be sorted is read to obtain the first data value.
5. The method according to claim 4, characterized in that The storing the second data value into the target database and clearing the data value to be sorted includes: Create a target storage table group according to the storage table group where the updated data value is located; storing the second data value in the target storage table group; The storage table group where the updated data value is located is cleared.
6. A data storage device, characterized in that: The device comprises: A data access volume acquisition module is used to obtain the data access volume of the target database within a preset time; A first data value acquisition module is used to read the data value to be sorted in the target database to obtain a first data value if the data access amount within the preset time is less than the preset access amount; the data value to be sorted is the value of the data in the target database that has not been sorted or needs to be sorted; A second data value acquisition module is used to sort the first data values to obtain a second data value; the sorting of the first data values to obtain the second data value includes: obtaining label information of each data value in the first data values; sorting each data value in the first data values based on the label information to obtain the second data value; The second data value storage module is used to store the second data value in the target database and clear the data value to be sorted.
7. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the data storage method according to any one of claims 1 to 5 by executing the computer instructions.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the data storage method according to any one of claims 1 to 5.
9. A computer program product, characterized in that The method comprises computer instructions for causing a computer to execute the data storage method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Method and device for writing index data into disk and terminal equipment
CN113961153A
Data sorting processing method and device, computer equipment, medium and program product
CN115544559A
Data management method and device, combinatorial library, electronic equipment and storage medium
CN115576947A
Data sorting method and device, electronic equipment and storage medium
CN116595059A
Data storage method and device, equipment, storage medium and program product
CN118152401A