Table operation method and related device
By splitting the update instructions and using the second table to assist in the update, the problem of long waiting time when updating the table is solved and the update speed is improved.
Patent Information
- Application Number
- CN202410791429.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-19
- Publication Date
- 2024-09-03
AI Technical Summary
In the database, when the table is updated, the table is in a locked state, which prevents other users from operating, resulting in long waiting times.
By splitting the first update instruction into multiple second update instructions, the data range updated by each second update instruction is smaller than the original instruction, and the second table is used to assist in updating the first table, thereby shortening the update time.
This shortens the time other users wait to access the table and increases update speed.
Smart Images

Figure CN118586370A
Abstract
Description
Technical Field
[0001] The present application relates to the field of database technology, and in particular to a table operation method and related devices. Background Art
[0002] The database stores a table containing a large amount of data; when a user performs an update operation on the table, such as a delete operation, an add operation, or a modify operation, the table is in a locked state; the table in the locked state cannot be operated by other users.
[0003] In summary, when a table is locked, other users can no longer operate the table. Other users need to wait until the table is updated before they can operate. Summary of the invention
[0004] In view of the above problems, the present application provides a table operation method and related devices to achieve the purpose of shortening the time other users have to wait for the table to be updated. The specific scheme is as follows:
[0005] The first aspect of the present application provides a table operation method, comprising:
[0006] Obtaining a first update instruction, where the first update instruction includes a first table identifier of a first table to be updated, an update operation for the first table, and a first update range, where the first update range refers to a data range of data to be updated;
[0007] The first table includes a first number of first logical partitions, and the first logical partitions include a plurality of data;
[0008] Based on the first update range and the first logical partition, a plurality of second update ranges are obtained, wherein an intersection of the plurality of second update ranges is an empty set, a union of the plurality of second update ranges is the first update range, data represented by each second update range belongs to the same first logical partition, and different second update ranges correspond to different first logical partitions;
[0009] For each of the second update ranges, changing the first update range in the first update instruction to the second update range to obtain a second update instruction;
[0010] storing a plurality of said second update instructions into a first queue;
[0011] If the second update instruction exists in the first queue, taking out one of the second update instructions from the first queue, and updating the first table by using the second update instruction;
[0012] If the second update instruction exists in the first queue, taking out one of the second update instructions from the first queue, changing the first table identifier in the second update instruction to the second table identifier to obtain a third update instruction, and updating the second table having the second table identifier by using the third update instruction;
[0013] The second table includes the first number of second logical partitions and status identifiers corresponding to the first number of the second logical partitions, respectively, and the second logical partition includes a plurality of data; a correspondence between the first logical partition and the second logical partition is pre-constructed; before executing the step of updating the first table by using the second update instruction, the first logical partition and the second logical partition having the corresponding relationship contain the same data;
[0014] updating the state flag of the second logical partition corresponding to the second update range included in the third update instruction in the second table to an updated flag;
[0015] If the plurality of second update instructions are all executed, switching the second table from an access-allowed state to a locked state;
[0016] From the preset correspondence relationship between the first logical partition and the second logical partition, searching for a target first logical partition corresponding to the second logical partition whose status is marked as an updated flag;
[0017] Update the target first logical partition in the first table by using the second logical area whose status mark is an updated mark;
[0018] The second table is updated based on the first table.
[0019] In a possible implementation, after receiving the first update instruction, the method further includes:
[0020] If the first update range represents that the amount of data to be updated is greater than or equal to a first preset threshold, the second table is switched from a locked state to an access allowed state.
[0021] In a possible implementation, after the step of updating the first table by using the second update instruction, the method further includes:
[0022] Acquire an update time of updating the first table by the second update instruction;
[0023] If the update time is less than the second preset threshold, and the first table is updated by the second update instruction, return to step 10, if the second update instruction exists in the first queue, take out one of the second update instructions from the first queue, and update the first table by the second update instruction;
[0024] If the update time is greater than or equal to the second preset threshold, execute the step: if the second update instruction exists in the first queue, take out a second update instruction from the first queue, change the first table identifier in the second update instruction to the second table identifier to obtain a third update instruction, and update the second table with the second table identifier through the third update instruction.
[0025] In a possible implementation, the method further includes:
[0026] receiving a plurality of operation instructions, wherein the operation instructions include a table identifier of a table to be operated, an operation action for the table, and an operation range, wherein the operation range refers to a data range of data to be operated;
[0027] Determine that the operation instruction in which the operation action is the update operation among the multiple operation instructions is the first update instruction; the update operation is a deletion action, a modification action, or an addition action;
[0028] storing a plurality of the first update instructions into a second queue;
[0029] Determine an operation instruction in which the operation action is a read action among the multiple operation instructions as a read instruction.
[0030] In a possible implementation, the method further includes:
[0031] Data is acquired from the first table through the read instruction.
[0032] In a possible implementation, the step of obtaining a first update instruction includes:
[0033] A first update instruction is obtained from the second queue.
[0034] A second aspect of the present application provides a table operation device, comprising:
[0035] A first acquisition module is used to acquire a first update instruction, where the first update instruction includes a first table identifier of a first table to be updated, an update operation for the first table, and a first update range, where the first update range refers to a data range of data to be updated;
[0036] The first table includes a first number of first logical partitions, and the first logical partitions include a plurality of data;
[0037] a second acquisition module, configured to obtain multiple second update ranges based on the first update range and the first logical partition, wherein the intersection of the multiple second update ranges is an empty set, the union of the multiple second update ranges is the first update range, the data represented by each second update range belongs to the same first logical partition, and different second update ranges correspond to different first logical partitions;
[0038] A third acquisition module, configured to change the first update range in the first update instruction to the second update range for each second update range, so as to obtain a second update instruction;
[0039] A first storage module, used for storing a plurality of the second update instructions into a first queue;
[0040] A first execution module, configured to take out a second update instruction from the first queue if the second update instruction exists in the first queue, and update the first table by using the second update instruction;
[0041] a second execution module, configured to, if the second update instruction exists in the first queue, take out one of the second update instructions from the first queue, change the first table identifier in the second update instruction to a second table identifier to obtain a third update instruction, and update the second table having the second table identifier by using the third update instruction;
[0042] The second table includes the first number of second logical partitions and status identifiers corresponding to the first number of the second logical partitions, respectively, and the second logical partition includes a plurality of data; a correspondence between the first logical partition and the second logical partition is pre-constructed; before executing the step of updating the first table by using the second update instruction, the first logical partition and the second logical partition having the corresponding relationship contain the same data;
[0043] A first updating module, configured to update a state flag of the second logical partition corresponding to the second update range included in the third updating instruction in the second table to an updated flag;
[0044] A first switching module, configured to switch the second table from an access-allowed state to a locked state if the plurality of second update instructions are all executed;
[0045] A search module, configured to search for a target first logical partition corresponding to the second logical partition whose status is marked as updated from a preset correspondence relationship between the first logical partition and the second logical partition;
[0046] A second updating module, configured to update the target first logical partition in the first table through the second logical area whose status identifier is an updated identifier;
[0047] A third updating module is configured to update the second table based on the first table.
[0048] In an optional implementation, the method further includes:
[0049] The second switching module is configured to switch the second table from a locked table state to an access allowed state if the first update range represents a data amount of data to be updated that is greater than or equal to a first preset threshold.
[0050] A third aspect of the present application provides a computer program product, comprising computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements the table operation method of the first aspect or any implementation of the first aspect.
[0051] A fourth aspect of the present application provides an electronic device, comprising at least one processor and a memory connected to the processor, wherein:
[0052] The memory is used to store computer programs;
[0053] The processor is used to execute the computer program so that the electronic device can implement the table operation method of the above-mentioned first aspect or any implementation manner of the first aspect.
[0054] A fifth aspect of the present application provides a computer storage medium, which carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement the table operation method of the above-mentioned first aspect or any implementation of the first aspect.
[0055] By means of the above technical scheme, the present application provides a table operation method, which obtains a first update instruction; splits the first update instruction into multiple second update instructions; the union of the second update ranges in the multiple second update instructions is the first update range in the first update instruction; the intersection of the second update ranges in the multiple second update instructions is an empty set; the embodiment of the present application includes a first table and one or more second tables, and the data in the second table is the same as that in the first table; different second update instructions are executed for the first table and the second table respectively; since the second update range corresponding to the second update instruction is smaller than the first update range, and different second update instructions are executed for the first table and the second table respectively, the time for completing the execution of all the second update instructions is shorter than the time for completing the execution of the first update instruction for the first table; updating the data in the corresponding first logical partition in the first table by the data in the second logical area whose status is marked as the updated mark in the second table is faster than updating the data in the first table in response to the second update instruction, so the speed of updating the first table by the method provided in the embodiment of the present application is faster than the speed of updating the first table by the first update instruction, thereby shortening the time for other users to wait to access the first table. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0057] Figure 1 A schematic diagram of a system architecture provided for this application;
[0058] Figure 2 A schematic diagram of an optional hardware structure of a terminal 100 provided in this application;
[0059] Figure 3 A schematic diagram of the structure of a server 200 provided in this application;
[0060] Figure 4 A flowchart of a table operation method provided for this application;
[0061] Figure 5 A schematic diagram of the structure of a table operation device provided in this application;
[0062] Figure 6 A schematic diagram of the structure of an electronic device provided in this application. DETAILED DESCRIPTION
[0063] The following describes the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation method section of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.
[0064] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0065] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0066] See also Figure 1 , Figure 1 A schematic diagram of a system architecture is shown. The system may include a terminal 100 and a server 200. The server 200 may include one or more servers ( Figure 1 In the example, a server is included, and the server 200 can provide the method provided in the embodiment of the present application for one or more terminals.
[0067] Among them, an application for accessing the database can be installed on the terminal 100, and the above application can provide an interface. The terminal 100 can receive relevant instructions entered by the user on the interface, such as operation instructions, and send the above instructions to the server 200. The server 200 can obtain processing results based on the received instructions and return the processing results to the terminal 100.
[0068] Exemplarily, the server 200 is installed with a database; exemplary, the database is independent of the server 200 ; exemplary, the terminal 100 can access the database through the server 200 .
[0069] It should be understood that in some optional implementations, the terminal 100 can also complete the action of interacting with the database based on the received instructions to obtain the processing results by itself without the need for the cooperation of the server, and the embodiments of the present application are not limited thereto.
[0070] Next describe Figure 1 The product form of the mid-terminal 100;
[0071] The terminal 100 in the embodiment of the present application can be a mobile phone, a tablet computer, a wearable device, a vehicle-mounted device, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc., and the embodiment of the present application does not impose any restrictions on this.
[0072] Figure 2 An optional hardware structure diagram of the terminal 100 is shown.
[0073] refer to Figure 2 As shown, the terminal 100 may include a radio frequency unit 110, a memory 120, an input unit 130, a display unit 140, a camera 150 (optional), an audio circuit 160 (optional), a speaker 161 (optional), a microphone 162 (optional), an earphone jack 163 (optional), a processor 170, an external interface 180, a power supply 190 and other components. Those skilled in the art will appreciate that Figure 2 This is merely an example of a terminal and does not constitute a limitation on the terminal. The terminal may include more or fewer components than shown in the figure, or a combination of certain components, or different components.
[0074] The input unit 130 can be used to receive input digital or character information, and generate key signal input related to the user settings and function control of the terminal. Specifically, the input unit 130 may include a touch screen 131 (optional) and / or other input devices 132. The touch screen 131 can collect the user's touch operations on or near it (such as the user's operation on or near the touch screen using any suitable object such as fingers, joints, stylus, etc.), and drive the corresponding connection device according to a pre-set program. The touch screen can detect the user's touch action on the touch screen, convert the touch action into a touch signal and send it to the processor 170, and can receive and execute the command sent by the processor 170; the touch signal at least includes the touch point coordinate information. The touch screen 131 can provide an input interface and an output interface between the terminal 100 and the user. In addition, the touch screen can be implemented using multiple types such as resistive, capacitive, infrared and surface acoustic wave. In addition to the touch screen 131, the input unit 130 can also include other input devices. Specifically, other input devices 132 may include, but are not limited to, one or more of a physical keyboard, function keys (such as a volume control key, a switch key, etc.), a trackball, a mouse, a joystick, and the like.
[0075] Among them, the input device 132 can receive input data and the like.
[0076] The display unit 140 may be used to display information input by the user or provided to the user, various menus of the terminal 100, interactive interfaces, file display and / or playback of any multimedia file. In the embodiment of the present application, the display unit 140 may be used to display an interface for inputting commands, processing results, etc.
[0077] The memory 120 can be used to store instructions and data. The memory 120 can mainly include an instruction storage area and a data storage area. The data storage area can store various data, such as multimedia files, texts, etc.; the instruction storage area can store software units such as operating systems, applications, instructions required for at least one function, or their subsets and extensions. It can also include a non-volatile random access memory; provide the processor 170 with hardware, software and data resources including management of computing and processing equipment, and support control software and applications. It is also used for the storage of multimedia files, and the storage of running programs and applications.
[0078] The processor 170 is the control center of the terminal 100. It uses various interfaces and lines to connect various parts of the entire terminal 100. By running or executing instructions stored in the memory 120 and calling data stored in the memory 120, it executes various functions of the terminal 100 and processes data, thereby controlling the terminal device as a whole. Optionally, the processor 170 may include one or more processing units; preferably, the processor 170 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface and application program, and the modem processor mainly processes wireless communication. It is understandable that the above-mentioned modem processor may not be integrated into the processor 170. In some embodiments, the processor and the memory may be implemented on a single chip, and in some embodiments, they may also be implemented separately on separate chips. The processor 170 may also be used to generate corresponding operation control signals, send them to corresponding components of the computing and processing device, read and process data in the software, especially read and process data and programs in the memory 120, so that each functional module therein performs corresponding functions, thereby controlling the corresponding components to act according to the requirements of the instructions.
[0079] The memory 120 may be used to store software codes related to the table operation method, the processor 170 may execute the steps of the table operation method, and may also schedule other units (such as the above-mentioned input unit 130 and display unit 140) to implement corresponding functions.
[0080] The radio frequency unit 110 (optional) can be used for receiving and sending information or receiving and sending signals during a call, for example, after receiving the downlink information of the base station, it is sent to the processor 170 for processing; in addition, the designed uplink data is sent to the base station. Generally, the RF circuit includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (Low Noise Amplifier, LNA), a duplexer, etc. In addition, the radio frequency unit 110 can also communicate with network devices and other devices through wireless communication. The wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile communication (Global System of Mobile communication, GSM), General Packet Radio Service (General Packet Radio Service, GPRS), Code Division Multiple Access (Code Division Multiple Access, CDMA), Wideband Code Division Multiple Access (Wideband Code Division Multiple Access, WCDMA), Long Term Evolution (Long Term Evolution, LTE), email, Short Messaging Service (SMS), etc.
[0081] In this embodiment of the present application, the RF unit 110 can send data to the server 200 and receive processing results sent by the server 200.
[0082] It should be understood that the radio frequency unit 110 is optional and can be replaced by other communication interfaces, such as a network port.
[0083] The terminal 100 also includes a power supply 190 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 170 through a power management system, so that the power management system can manage functions such as charging, discharging, and power consumption.
[0084] The terminal 100 further includes an external interface 180 , which may be a standard Micro USB interface or a multi-pin connector, and may be used to connect the terminal 100 to communicate with other devices, or to connect a charger to charge the terminal 100 .
[0085] Although not shown, the terminal 100 may also include a flashlight, a wireless fidelity (WiFi) module, a Bluetooth module, sensors with different functions, etc., which are not described in detail here. Some or all of the methods described below may be applied in the following embodiments. Figure 2 In the terminal 100 shown.
[0086] Next describe Figure 1 The product form of the server 200;
[0087] Figure 3 A structural diagram of a server 200 is provided, such as Figure 3 As shown, the server 200 includes a bus 201, a processor 202, a communication interface 203, and a memory 204. The processor 202, the memory 204, and the communication interface 203 communicate with each other via the bus 201.
[0088] The bus 201 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0089] The processor 202 may be any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0090] The memory 204 may include a volatile memory, such as a random access memory (RAM). The memory 204 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard drive (HDD), or a solid state drive (SSD).
[0091] The memory 204 may be used to store software codes related to the table operation method, and the processor 202 may execute the steps of the table operation method of the chip, and may also schedule other units to implement corresponding functions.
[0092] It should be understood that the above-mentioned terminal 100 and server 200 can be centralized or distributed devices, and the processors in the above-mentioned terminal 100 and server 200 (such as processor 170 and processor 202) can be hardware circuits (such as application specific integrated circuit (ASIC), field-programmable gate array (FPGA), general-purpose processor, digital signal processor (DSP), microprocessor or microcontroller, etc.), or a combination of these hardware circuits. For example, the processor can be a hardware system with an instruction execution function, such as a CPU, DSP, etc., or a hardware system without an instruction execution function, such as an ASIC, FPGA, etc., or a combination of the above-mentioned hardware systems without an instruction execution function and hardware systems with an instruction execution function.
[0093] In the related art, the process of operating a table includes the following steps A1 to A4.
[0094] Step A1: receiving an operation instruction, wherein the operation instruction includes a table identifier of a table to be operated, an operation action for the table, and an operation range, wherein the operation range refers to a data range of data to be operated.
[0095] Step A2: operating the table through the operation instruction, and setting the state of the table to a locked table state.
[0096] In the locked table state, only the operation instructions mentioned in step A2 can operate the table, and other operation instructions cannot operate the table.
[0097] Step A3: During the process of operating the table through the operation instruction, if an operation instruction is received again, the operation instruction is stored in the third queue.
[0098] The third queue stores operation instructions corresponding to each user.
[0099] Step A4: If the operation instruction completes the operation on the table, the state of the table is switched from the locked state to the access allowed state, an operation instruction is taken out from the third queue, and the process returns to step A2.
[0100] It is understandable that in the process of operating the table through the operation instruction, the data A of the table may be deleted, added or changed; if the table is in the access permission state, the data A in the table may be deleted, added or changed again, resulting in data confusion. The following example is used to illustrate.
[0101] For example, data A is the user's ID number, an operation instruction A11 is to change the second digit of ID number 01 to 1, and an operation instruction A12 is to change the second digit of ID number 01 to 2. If operation instruction A12 is executed during the execution of operation instruction A11, it is impossible to determine whether the second digit of ID number 01 is changed to 1 or 2, resulting in data confusion. Therefore, during the execution of a certain operation instruction (an operation instruction taken out from the third queue), the table is set to a locked table state. However, because the table is in a locked table state, the operation instructions of other users (the operation instructions taken out again from the third queue are the operation instructions of other users) cannot operate the table. Other users need to wait until the operation instruction in step A2 completes the operation of the table before they can operate the table; if the operation instruction takes a long time to operate the table, other users need to wait a long time before they can operate the table.
[0102] In order to solve the above problems, the embodiment of the present application provides a table operation method. The table operation method of the embodiment of the present application is described in detail below with reference to the accompanying drawings.
[0103] Reference Figure 4 , Figure 4 A flowchart of a table operation method provided in an embodiment of the present application is shown in FIG. Figure 4 As shown, a table operation method provided in an embodiment of the present application may include steps 401 to 411, and these steps are described in detail below.
[0104] Step 401: Obtain a first update instruction, where the first update instruction includes a first table identifier of a first table to be updated, an update operation for the first table, and a first update range, where the first update range refers to a data range of data to be updated.
[0105] The first table includes a first number of first logical partitions, and the first logical partition includes a plurality of data. Exemplarily, the first table is a table with a data volume exceeding 10 million data. Exemplarily, the embodiment of the present application can be applied to an application scenario of batch updating of the first table.
[0106] The following description is made by taking the first table as the user information table as an example, and see Table 1 for details.
[0107] Table 1
[0108]
[0109] The first table includes a header and an information area. The header includes multiple fields. For example, the header of Table 1 includes 4 fields, which are: ID number, number of accounts opened, card opening type and card opening time. The information area includes multiple data. For example, each row starting from the second row in Table 1 is a piece of data.
[0110] Exemplarily, the first table identifier includes a name of the first table and / or a first table ID.
[0111] Exemplarily, the first update instruction may be a delete instruction, an add instruction, or a modify instruction.
[0112] It can be understood that, since the operation is performed on the first table stored in the database, the first update instruction needs to comply with the instruction required by the database. The first update instruction is described below with an example.
[0113] If the first update instruction is a modification instruction, assuming that the first table identifier is the name of the first table, the name of the first table is table1, and the field value of the "time" field in the first table needs to be modified, then the modification instruction can be: updatetable1 set time = date(); exemplarily, date() is a time function, and the specific time can be obtained through this time function.
[0114] The update operation and the first update range are described below in conjunction with the modification instruction. The update operation is "update", and since the update range is not limited, the data to be updated represented by the first update range is all the data in table1.
[0115] If the first update instruction is an add instruction, illustratively, the add instruction can be to add multiple data, and / or, to add multiple columns of data. The following is an example of adding an instruction to add one or more data. Assume that the first table identifier is the name of the first table, and the name of the first table is table1. Assume that table1 is as shown in Table 1, including four fields: ID number, number of accounts opened, account opening type, and card opening time. The add instruction can be: insert into table1 (ID number, number of accounts opened, account opening type, card opening time) values (333333333333, 1, savings card, May 16, 2024).
[0116] The update operation and the first update range are described below in conjunction with the add instruction. The update operation is "insert", and the data to be updated represented by the first update range is a piece of data.
[0117] If the first update instruction is a delete instruction, the first table identifier is the name of the first table, the name of the first table is table1, and it is assumed that the first table is as shown in Table 1, and it is necessary to delete all data in Table 1 with card opening time from January 1, 1990 to December 31, 2010, then the delete instruction can be: DELETE from table1 where card opening time between'1990-01-01 00:00:00'and'2010-12-31 00:00:00'.
[0118] The update operation and the first update range are described below in conjunction with the delete instruction. The update operation is "DELETE", and the data to be updated represented by the first update range are all data with card opening time between '1990-01-01 00:00:00' and '2010-12-31 00:00:00'.
[0119] Step 402: Based on the first update range and the first logical partition, obtain multiple second update ranges.
[0120] The intersection of the multiple second update ranges is an empty set, the union of the multiple second update ranges is the first update range, the data to be updated represented by each second update range belongs to the same first logical partition, and different second update ranges correspond to different first logical partitions.
[0121] Exemplarily, the number of data items included in different first logical partitions is the same. Exemplarily, the number of data items included in different first logical partitions is not completely the same, or is completely different.
[0122] Exemplarily, the rule for logically partitioning the data in the first table may be: partitioning according to a field in the first table, such as partitioning according to the card opening time in Table 1, or partitioning according to the province to which the ID card number belongs.
[0123] The implementation process of step 402 is described in detail below. Exemplarily, step 402 includes the following steps B1 to B3.
[0124] Step B1: Determine a plurality of first logical partitions involved in a first update range.
[0125] The following describes the first logical partition by taking an example.
[0126] Assume that the first table is as shown in Table 1, and assume that the first logical partition is divided according to the card opening time, and the data with the card opening time belonging to the same year belongs to the same first logical partition. If the first table includes card opening data for a total of 10 years from 2010 to 2019, the first table corresponds to 10 first logical partitions. The 10 first logical partitions are as follows: the first logical partition 0001 containing data with card opening time of [January 1, 2010, December 31, 2010], the first logical partition 0002 containing data with card opening time of [January 1, 2011, December 31, 2011], ..., the first logical partition 0010 containing data with card opening time of [January 1, 2019, December 31, 2019].
[0127] If the data to be updated represented by the first update range is data with a card opening time of [October 1, 2011, May 30, 2013], the first logical partitions involved in the first update range are the first logical partition 0002, the first logical partition 0003 and the first logical partition 0004.
[0128] Step B2: for each first logical partition determined in step B1, determine the intersection of the first logical partition and the data to be updated represented by the first update range as a second update range, thereby obtaining multiple second update ranges.
[0129] The first logical partition 0002 includes data with card activation time of [January 1, 2011, December 31, 2011], and the data to be updated represented by the first update range is data with card activation time of [October 1, 2011, May 30, 2013]. The intersection of the first logical partition 0002 and the data to be updated represented by the first update range is: data with card activation time of [January 1, 2011, December 31, 2011]. Therefore, the second update range is: card activation time of [October 1, 2011, December 31, 2011].
[0130] The first logical partition 0003 includes data with card activation time of [January 1, 2012, December 31, 2012], and the data to be updated represented by the first update range is data with card activation time of [October 1, 2011, May 30, 2013]. The intersection of the first logical partition 0003 and the data to be updated represented by the first update range is: data with card activation time of [January 1, 2012, December 31, 2012]. Therefore, the second update range is: card activation time of [January 1, 2012, December 31, 2012].
[0131] The first logical partition 0004 includes data with card activation time of [January 1, 2013, December 31, 2013], and the data to be updated represented by the first update range is data with card activation time of [October 1, 2011, May 30, 2013]. The intersection of the first logical partition 0004 and the data to be updated represented by the first update range is: data with card activation time of [January 1, 2013, May 30, 2013]. Therefore, the second update range is: card activation time of [January 1, 2013, May 30, 2013].
[0132] Step 403: For each of the second update ranges, change the first update range in the first update instruction to the second update range to obtain a second update instruction.
[0133] Still taking the example in step 402 for explanation, if the multiple second update ranges are: the second update range of card opening time [October 1, 2011, December 31, 2011], the second update range of card opening time [January 1, 2012, December 31, 2012], and the second update range of card opening time [January 1, 2013, May 30, 2013].
[0134] Assume that the first update instruction is DELETE from table1 where card opening time between'2011-10-01 00:00:00'and'2013-05-30 00:00:00'; the second update instruction obtained for the second update range of card opening time [October 1, 2011, December 31, 2011] is: DELETE from table1 where card opening time between'2011-10-01 00:00:00'and'2011-12-31 00:00:00'; the second update instruction obtained for the second update range of card opening time [January 1, 2012, December 31, 2012] is: DELETE from table1where card opening time between'2012-01-01 00:00:00'and'2012-12-31 00:00:00'; for the second update range of the card opening time of [January 1, 2013, May 30, 2013], the second update instruction obtained is: DELETE from table1 where card opening time between'2013-01-01 00:00:00'and'2013-05-3000:00:00'.
[0135] Step 404: Store a plurality of the second update instructions into the first queue.
[0136] Exemplarily, a plurality of second update instructions may be randomly stored in the first queue.
[0137] Exemplarily, the multiple second update instructions may be sorted according to the order in which the data to be updated are located in the first table to obtain a sorting result, and the second update instructions may be sequentially stored in the first queue from back to front according to the sorting result.
[0138] Exemplarily, the plurality of second update instructions may be stored in the first queue in descending order according to the identifiers of the first logical partitions corresponding to the second update ranges in the second update instructions.
[0139] Step 405: If the second update instruction exists in the first queue, take out a second update instruction from the first queue, and update the first table through the second update instruction.
[0140] It can be understood that, since the data range updated by the second update instruction is smaller than that updated by the first update instruction, the time for executing the second update instruction is greatly shortened compared with the time for executing the first update instruction.
[0141] Step 406: If the second update instruction exists in the first queue, take out a second update instruction from the first queue, change the first table identifier in the second update instruction to the second table identifier to obtain a third update instruction, and update the second table with the second table identifier through the third update instruction.
[0142] Among them, the second table includes the first number of second logical partitions and the status identifiers corresponding to the first number of the second logical partitions respectively, and the second logical partition includes multiple data; the correspondence between the first logical partition and the second logical partition is pre-constructed; before executing the step of updating the first table through the second update instruction, the first logical partition and the second logical partition with the corresponding relationship contain the same data.
[0143] Exemplarily, the number of the second table may be one or more. The second table is stored in a database.
[0144] The third update instruction is described below with an example.
[0145] Assume that the second update instruction is: DELETE from table1 where card opening time between'2011-10-0100:00:00'and'2011-12-31 00:00:00', and assume that the second table identifier of the second table is table2, then the third update instruction is: DELETE from table2 where card opening time between'2011-10-01 00:00:00'and'2011-12-31 00:00:00'.
[0146] The following example illustrates the relationship between the first table and the second table.
[0147] Before executing step 405, the second table includes the data in the first table and status identifiers corresponding to the plurality of second logical partitions.
[0148] Exemplarily, the status identifier may be composed of one or more characters. Exemplarily, a status identifier of 0 indicates that the data in the second logical partition is not updated, and a status identifier of 1 indicates that at least part of the data in the second logical partition is updated.
[0149] The number of first logical partitions included in the first table and the number of second logical partitions included in the second table are the same, both being the first number. The way of dividing logical partitions in the first table is the same as the way of dividing logical partitions in the second table; therefore, before executing step 405 and step 406, that is, before the first table and the second table are updated, there are first logical partitions in the first number of first logical partitions that have the same data as that contained in any second logical partition. This is explained by an example below.
[0150] Assuming that the first table is as shown in Table 1, the first logical partition in the first table is divided according to the card activation time, and the data with the card activation time in the same year belongs to the same first logical partition. Then the second logical partition in the second table is divided according to the card activation time, and the data with the card activation time in the same year belongs to the same second logical partition.
[0151] It is understandable that the first update instruction is split into multiple second update instructions, and the data range of the data to be updated by the second update instruction is smaller than the data range of the data to be updated by the first update instruction, so the execution speed of the second update instruction is faster than that of the first update instruction. Moreover, different second update instructions can be executed for the first table and the second table respectively, so the sum of the time to execute all the second update instructions is less than the time to execute the first update instruction for one first table, thereby shortening the time the first table is in the locked table state, that is, shortening the time other users wait to operate the first table.
[0152] Step 407: Update the status flag of the second logical partition corresponding to the second update range included in the third update instruction in the second table to an updated flag.
[0153] Still taking step 403 as an example, the number of the multiple second update instructions is 3, which are: "DELETE from table1 where card opening time between'2011-10-01 00:00:00'and'2011-12-3100:00:00'", "DELETE from table1 where card opening time between'2012-01-01 00:00:00'and'2012-12-31 00:00:00'", and "DELETE from table1 where card opening time between'2013-01-0100:00:00'and'2013-05-30 00:00:00'". Assume that the second update instruction "DELETE from table1 where card opening time between'2011-10-01 00:00:00'and'2011-12-3100:00:00'" is executed for the first table (corresponding to the first logical partition 0002); then the first table identifier table1 in the second update instruction "DELETE from table1 where card opening time between'2012-01-01 00:00:00'and'2012-12-31 00:00:00'" is changed to the second table identifier table2, and a third update instruction is obtained; Assume that the third update instruction "DELETE from table2 where card opening time between'2012-01-01 00:00:00'and'2012-12-31 00:00:00'" is executed for the second table (corresponding to the first logical partition 0003); the second update instruction "DELETE from table1 where card opening time between'2012-01-01 00:00:00'and'2012-12-31 00:00:00'" is executed for the first table. table1where card opening time between'2013-01-01 00:00:00'and'2013-05-30 00:00:00'" (corresponding to the first logical partition 0004). The second logical partition corresponding to the second update range included in the third update instruction refers to the second logical partition corresponding to the first logical partition 0003 corresponding to the second update range included in the third update instruction. Because the correspondence between the first logical partition and the second logical partition is pre-constructed, the second logical partition corresponding to the first logical partition 0003 can be obtained.
[0154] It is understandable that the second table is used to assist in updating the first table. If the second table is updated by the third update instruction, then the second update instruction corresponding to the third update instruction will no longer update the first table, so it is necessary to update the data contained in the second logical partition whose status is marked as updated in the second table to the first table. It is understandable that the speed of updating the data in the second table to the first table in the database is faster than the speed of updating the first table by the SQL statement (such as the second update instruction).
[0155] Step 408: If the plurality of second update instructions are all executed, switch the second table from the access-allowed state to the locked state.
[0156] It can be understood that multiple second update instructions have been executed, which is equivalent to the first update instruction being executed. Since some of the second update instructions update the first table, and some of the second update instructions update the second table, the data updated in the first table and the second table are different. If the second table is in the access allowed state at this time, if the operation instruction is a read instruction, the data read from the second table may be wrong, so it is necessary to switch the second table to the locked table state.
[0157] Step 409: From the preset correspondence relationship between the first logical partition and the second logical partition, search for a target first logical partition corresponding to the second logical partition whose status mark is an updated mark.
[0158] Step 410: Update the target first logical partition in the first table through the second logical area whose status is marked as updated.
[0159] After step 410 is executed, it is equivalent to performing an update operation on the first table through the first update instruction.
[0160] Exemplarily, after step 410 is executed, the first table may be switched from a locked table state to an access allowed state.
[0161] Step 411: Update the second table based on the first table.
[0162] It is understandable that before executing steps 401 to 410 , it is necessary to ensure that the data in the first table and the second table are the same, so step 411 needs to be executed.
[0163] In an optional implementation, the method further includes: if the second table is updated based on the first table, returning to step 401.
[0164] The embodiment of the present application provides a table operation method, which obtains a first update instruction; splits the first update instruction into multiple second update instructions; the union of the second update ranges in the multiple second update instructions is the first update range in the first update instruction; the intersection of the second update ranges in the multiple second update instructions is an empty set; the embodiment of the present application includes a first table and one or more second tables, and the data in the second table is the same as that in the first table; different second update instructions are executed for the first table and the second table respectively; since the second update range corresponding to the second update instruction is smaller than the first update range, and different second update instructions are executed for the first table and the second table respectively, the time to complete the execution of all the second update instructions is shorter than the time to complete the execution of the first update instruction for the first table; updating the data in the corresponding first logical partition in the first table by the data in the second logical area with the status mark as the updated mark in the second table is faster than updating the data in the first table in response to the second update instruction, so the speed of updating the first table by the method provided by the embodiment of the present application is faster than the speed of updating the first table by the first update instruction, thereby shortening the time for other users to wait to access the first table.
[0165] In the embodiment of the present application, executing the third update instruction on the second table is equivalent to executing the second update instruction corresponding to the third update instruction on the second table.
[0166] In one possible implementation, after step 401 obtains the first update instruction, if the data to be updated represented by the first update range in the first update instruction is very small, for example, the data to be updated represented by the first update range is only one piece, then the speed of updating the first table through the first update instruction is very fast, and there is no need to split the first update range into multiple second update ranges, and there is no need to obtain multiple second update instructions. Based on this, the present application also provides the following method: if the amount of data to be updated represented by the first update range is greater than or equal to a first preset threshold, switch the second table from a locked table state to an access allowed state. Exemplarily, if the amount of data to be updated represented by the first update range is less than the first preset threshold, keep the second table in a locked table state.
[0167] Exemplarily, the first preset threshold may be determined based on actual conditions, which is not limited here. Exemplarily, the first preset threshold may be 10M.
[0168] It is understandable that if the second table is in a locked state, the third update instruction cannot be executed on the second table.
[0169] It is understandable that the reason why it takes a long time to execute the first update instruction for the first table includes: the first update instruction is delayed due to some reasons. Exemplarily, if the first update instruction is not delayed, the first update instruction can also be executed for the first table. Based on this, the present application also provides the following method, which is executed after step 405, and includes the following steps C1 to C3.
[0170] Step C1: Acquire the update time of updating the first table by the second update instruction.
[0171] Step C2: If the update time is less than the second preset threshold, and the first table is updated completely through the second update instruction, return to step 405 .
[0172] If the update time is less than the second preset threshold, it means that the second update instruction is completed normally without delay. Exemplarily, the embodiment of the present application preferentially executes the second update instruction on the first table, and if a second update instruction is completed with delay, the second update instruction is executed on the second table.
[0173] Step C3: If the update time is greater than or equal to the second preset threshold, execute step 406.
[0174] Exemplarily, the second preset thresholds corresponding to different second update instructions may be the same or different.
[0175] Exemplarily, the second preset threshold may be determined based on actual conditions and is not limited here.
[0176] In an optional implementation, the following steps D1 to D4 are also included.
[0177] Step D1: receiving a plurality of operation instructions, wherein the operation instructions include a table identifier of a table to be operated, an operation action for the table, and an operation range, wherein the operation range refers to a data range of data to be operated.
[0178] Exemplarily, different operation instructions may come from different terminals. Exemplarily, different operation instructions may come from the same terminal.
[0179] For the description of the table identifier, please refer to the description of the first table identifier. For the description of the operation range, please refer to the description of the first update range, which will not be repeated here.
[0180] Step D2: Determine that the operation instruction whose operation action is the update operation among the multiple operation instructions is the first update instruction; the update operation is a deletion action, a modification action, or an addition action.
[0181] Step D3: Store the plurality of first update instructions into a second queue.
[0182] Exemplarily, step 401 includes: obtaining one of the first update instructions from the second queue.
[0183] Exemplarily, different first update instructions originate from different terminals; exemplary, different first update instructions originate from the same terminal.
[0184] Exemplarily, if the number of first update instructions stored in the second queue is large, the second preset threshold may be reduced.
[0185] Step D4: Determine that the operation instruction whose operation action is a read action among the multiple operation instructions is a read instruction.
[0186] Exemplarily, after step D4, the method further includes: acquiring data from the first table through the read instruction.
[0187] If the operation instruction is a read instruction, since the data in the first table is not updated, the data can be directly read from the first table.
[0188] Exemplarily, multiple read instructions may be executed on the first table at the same time.
[0189] A table operation method provided by an embodiment of the present application is introduced above, and a device for executing the above table operation method will be introduced below.
[0190] See also Figure 5 , Figure 5 This is a schematic diagram of the structure of a table operation device provided in an embodiment of the present application. Figure 5 As shown, the table operation device comprises:
[0191] A first acquisition module 501 is used to acquire a first update instruction, where the first update instruction includes a first table identifier of a first table to be updated, an update operation for the first table, and a first update range, where the first update range refers to a data range of data to be updated;
[0192] The first table includes a first number of first logical partitions, and the first logical partitions include a plurality of data;
[0193] A second acquisition module 502 is configured to obtain multiple second update ranges based on the first update range and the first logical partition, where the intersection of the multiple second update ranges is an empty set, the union of the multiple second update ranges is the first update range, the data to be updated represented by each second update range belongs to the same first logical partition, and different second update ranges correspond to different first logical partitions;
[0194] A third acquisition module 503, configured to change the first update range in the first update instruction to the second update range for each second update range, so as to obtain a second update instruction;
[0195] A first storage module 504, configured to store a plurality of the second update instructions into a first queue;
[0196] A first execution module 505 is configured to take out a second update instruction from the first queue if the second update instruction exists in the first queue, and update the first table by using the second update instruction;
[0197] A second execution module 506 is configured to, if the second update instruction exists in the first queue, take out a second update instruction from the first queue, change the first table identifier in the second update instruction to a second table identifier to obtain a third update instruction, and update the second table having the second table identifier by using the third update instruction;
[0198] The second table includes the first number of second logical partitions and status identifiers corresponding to the first number of the second logical partitions, respectively, and the second logical partition includes a plurality of data; a correspondence between the first logical partition and the second logical partition is pre-constructed; before executing the step of updating the first table by using the second update instruction, the first logical partition and the second logical partition having the corresponding relationship contain the same data;
[0199] A first updating module 507, configured to update a state flag of the second logical partition corresponding to the second update range included in the third updating instruction in the second table to an updated flag;
[0200] A first switching module 508, configured to switch the second table from an access-allowed state to a locked state if the plurality of second update instructions are all executed;
[0201] A search module 509 is configured to search, from a preset correspondence relationship between the first logical partition and the second logical partition, a target first logical partition corresponding to the second logical partition whose status is marked as updated;
[0202] A second updating module 510 is configured to update the target first logical partition in the first table through the second logical area whose status is marked as an updated flag;
[0203] The third updating module 511 is configured to update the second table based on the first table.
[0204] In an optional implementation, the method further includes:
[0205] The second switching module is configured to switch the second table from a locked table state to an access allowed state if the first update range represents a data amount of data to be updated that is greater than or equal to a first preset threshold.
[0206] In an optional implementation, the method further includes:
[0207] A fourth acquisition module, used to acquire an update time of updating the first table by the second update instruction;
[0208] A first trigger module, configured to trigger a first execution module if the update time is less than a second preset threshold and the first table is updated completely by the second update instruction;
[0209] The second trigger module is used to trigger the second execution module if the update time is greater than or equal to the second preset threshold.
[0210] In an optional implementation, the method further includes:
[0211] A receiving module, configured to receive a plurality of operation instructions, wherein the operation instructions include a table identifier of a table to be operated, an operation action for the table, and an operation range, wherein the operation range refers to a data range of data to be operated;
[0212] A first determining module, configured to determine that an operation instruction in which the operation action is the update operation among the plurality of operation instructions is the first update instruction; the update operation is a deletion action, a modification action, or an addition action;
[0213] A second storage module, used for storing a plurality of the first update instructions into a second queue;
[0214] The second determining module is used to determine that the operation instruction whose operation action is a read action among the multiple operation instructions is a read instruction.
[0215] In an optional implementation, the method further includes:
[0216] A fifth acquisition module is used to acquire data from the first table through the read instruction.
[0217] In an optional implementation, the first acquisition module includes:
[0218] An acquiring unit is used to acquire one of the first update instructions from the second queue.
[0219] In an optional implementation, the method further includes:
[0220] A third triggering module is configured to trigger a first obtaining module if the second table is updated based on the first table.
[0221] The present application also provides an electronic device in an embodiment. Figure 6 As shown, it shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present application. The electronic device in the embodiments of the present application may include but is not limited to fixed terminals such as mobile phones, notebook computers, PDAs (personal digital assistants), PADs (tablet computers), desktop computers, etc. Figure 6 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0222] like Figure 6 As shown, the electronic device may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. When the electronic device is powered on, various programs and data required for the operation of the electronic device are also stored in the RAM 603. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0223] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a memory card, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 An electronic device having various devices is shown, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0224] An embodiment of the present application also provides a computer program product including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements any table operation method provided in the embodiment of the present application.
[0225] A computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any table operation method provided in the embodiment of the present application.
[0226] The table operation method and related device provided by the present invention can be used in the financial field or other fields, for example, can be used in database application scenarios in the financial field. Other fields are any fields other than the financial field, for example, the field of teaching technology. The above is only an example and does not limit the application field of the table operation method and related device provided by the present invention.
[0227] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0228] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0229] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0230] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.
Claims
1. A table operation method, characterized in that: include: Obtaining a first update instruction, where the first update instruction includes a first table identifier of a first table to be updated, an update operation for the first table, and a first update range, where the first update range refers to a data range of data to be updated; The first table includes a first number of first logical partitions, and the first logical partitions include a plurality of data; Based on the first update range and the first logical partition, a plurality of second update ranges are obtained, the intersection of the plurality of second update ranges is an empty set, the union of the plurality of second update ranges is the first update range, the data to be updated represented by each second update range belongs to the same first logical partition, and different second update ranges correspond to different first logical partitions; For each of the second update ranges, changing the first update range in the first update instruction to the second update range to obtain a second update instruction; storing a plurality of said second update instructions into a first queue; If the second update instruction exists in the first queue, taking out one of the second update instructions from the first queue, and updating the first table by using the second update instruction; If the second update instruction exists in the first queue, taking out one of the second update instructions from the first queue, changing the first table identifier in the second update instruction to the second table identifier to obtain a third update instruction, and updating the second table having the second table identifier by using the third update instruction; The second table includes the first number of second logical partitions and status identifiers corresponding to the first number of the second logical partitions, respectively, and the second logical partition includes a plurality of data; a correspondence between the first logical partition and the second logical partition is pre-constructed; before executing the step of updating the first table by using the second update instruction, the first logical partition and the second logical partition having the corresponding relationship contain the same data; updating the state flag of the second logical partition corresponding to the second update range included in the third update instruction in the second table to an updated flag; If the plurality of second update instructions are all executed, switching the second table from an access-allowed state to a locked state; From the preset correspondence relationship between the first logical partition and the second logical partition, searching for a target first logical partition corresponding to the second logical partition whose status is marked as an updated flag; Update the target first logical partition in the first table by using the second logical area whose status mark is an updated mark; The second table is updated based on the first table.
2. The table operation method according to claim 1, characterized in that: After receiving the first update instruction, the method further includes: If the first update range represents that the amount of data to be updated is greater than or equal to a first preset threshold, the second table is switched from a locked state to an access allowed state.
3. The table operation method according to any one of claims 1 or 2, characterized in that: After the step of updating the first table by the second update instruction, the method further includes: Acquire an update time of updating the first table by the second update instruction; If the update time is less than the second preset threshold, and the first table is updated by the second update instruction, return to step 10, if the second update instruction exists in the first queue, take out one of the second update instructions from the first queue, and update the first table by the second update instruction; If the update time is greater than or equal to the second preset threshold, execute the step: if the second update instruction exists in the first queue, take out a second update instruction from the first queue, change the first table identifier in the second update instruction to the second table identifier to obtain a third update instruction, and update the second table with the second table identifier through the third update instruction.
4. The table operation method according to claim 3, characterized in that: Also includes: receiving a plurality of operation instructions, wherein the operation instructions include a table identifier of a table to be operated, an operation action for the table, and an operation range, wherein the operation range refers to a data range of data to be operated; Determine that the operation instruction in which the operation action is the update operation among the multiple operation instructions is the first update instruction; the update operation is a deletion action, a modification action, or an addition action; storing a plurality of the first update instructions into a second queue; Determine an operation instruction in which the operation action is a read action among the multiple operation instructions as a read instruction.
5. The table operation method according to claim 4, characterized in that: Also includes: Data is acquired from the first table through the read instruction.
6. The table operation method according to claim 4, characterized in that: The step of obtaining the first update instruction comprises: A first update instruction is obtained from the second queue.
7. A table operation device, characterized in that: include: A first acquisition module is used to acquire a first update instruction, where the first update instruction includes a first table identifier of a first table to be updated, an update operation for the first table, and a first update range, where the first update range refers to a data range of data to be updated; The first table includes a first number of first logical partitions, and the first logical partitions include a plurality of data; a second acquisition module, configured to obtain multiple second update ranges based on the first update range and the first logical partition, wherein the intersection of the multiple second update ranges is an empty set, the union of the multiple second update ranges is the first update range, the data to be updated represented by each second update range belongs to the same first logical partition, and different second update ranges correspond to different first logical partitions; A third acquisition module, configured to change the first update range in the first update instruction to the second update range for each second update range, so as to obtain a second update instruction; A first storage module, used for storing a plurality of the second update instructions into a first queue; A first execution module, configured to take out a second update instruction from the first queue if the second update instruction exists in the first queue, and update the first table by using the second update instruction; a second execution module, configured to, if the second update instruction exists in the first queue, take out one of the second update instructions from the first queue, change the first table identifier in the second update instruction to a second table identifier to obtain a third update instruction, and update the second table having the second table identifier by using the third update instruction; The second table includes the first number of second logical partitions and status identifiers corresponding to the first number of the second logical partitions, respectively, and the second logical partition includes a plurality of data; a correspondence between the first logical partition and the second logical partition is pre-constructed; before executing the step of updating the first table by using the second update instruction, the first logical partition and the second logical partition having the corresponding relationship contain the same data; A first updating module, configured to update a state flag of the second logical partition corresponding to the second update range included in the third updating instruction in the second table to an updated flag; A first switching module, configured to switch the second table from an access-allowed state to a locked state if the plurality of second update instructions are all executed; A search module, configured to search for a target first logical partition corresponding to the second logical partition whose status is marked as updated from a preset correspondence relationship between the first logical partition and the second logical partition; A second updating module, configured to update the target first logical partition in the first table through the second logical area whose status identifier is an updated identifier; A third updating module is configured to update the second table based on the first table.
8. A computer program product, characterized in that It comprises computer-readable instructions, and when the computer-readable instructions are executed on an electronic device, the electronic device implements the table operation method as claimed in any one of claims 1 to 6.
9. An electronic device, characterized in that: The method comprises at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program so that the electronic device can implement the table operation method as described in any one of claims 1 to 6.
10. A computer storage medium, characterized in that: The storage medium carries one or more computer programs, and when the one or more computer programs are executed by an electronic device, the electronic device can implement the table operation method as described in any one of claims 1 to 6.
