Table data deletion method, device, computer equipment and storage medium

By adopting multi-threaded search and batch deletion methods in the relational data management system, the problem of low efficiency in deleting large-scale table data is solved, and more efficient data processing is achieved.

CN114372071BActive Publication Date: 2025-09-30CHINA PING AN LIFE INSURANCE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210028519.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-11
Publication Date
2025-09-30
Estimated Expiration
2042-01-11

AI Technical Summary

Technical Problem

Existing technologies are inefficient and time-consuming when deleting large-scale table data in relational data management systems. They can also easily cause tables to be locked, impacting subsequent program development and operational maintenance.

Method used

Use multi-threaded search to find the unique identifier in the table data, sort it according to preset rules to form a data set, store it in an array variable, and perform deletion operations in batches with multiple threads.

Benefits of technology

Through block and multi-thread processing, logical read operations are reduced, deletion efficiency is improved, and running time is shortened.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114372071B_ABST
    Figure CN114372071B_ABST
Patent Text Reader

Abstract

The embodiment of the present application belongs to the field of big data, and relates to a table data deletion method, including searching for a unique identifier for each row of data in the table data to be deleted in a database in multiple threads according to a search code; sorting a plurality of the unique identifiers according to preset rules to form a plurality of data sets; storing the sorted plurality of the data sets into a preset array variable; and performing deletion operations on the data to be deleted in batches and multiple threads according to the array variable. The present application also provides a table data deletion device, a computer device, and a storage medium. Since the data in the table data is stored in blocks, the present application can identify the data through the unique identifier of each record in the table data, thereby realizing block deletion of the table data, reducing the operation of logical reads, and at the same time improving the efficiency of deletion and reducing the running time through batch and multi-thread operations.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of big data technology, and in particular to a table data deletion method, apparatus, computer equipment, and storage medium. Background Art

[0002] In a relational data management system (Oracle), it's often necessary to delete table data according to specified conditions based on actual business needs. For some large tables, the amount of data deleted each time can reach around 50 million. The existing logic is to index the fields involved in the filtering conditions and submit the filtered data for deletion in batches to prevent direct deletions from locking the table.

[0003] Although the above logic solves the problem of locked tables, the execution efficiency is low and the entire deletion process is time-consuming. For example, deleting approximately 50 million rows of data takes 10 hours. Furthermore, the deletion efficiency decreases as time goes on, and table lookups become increasingly slow. As a result, each deletion requires the assistance of a DBA to lower the table watermark, which is extremely detrimental to subsequent program development and operation and maintenance. Summary of the Invention

[0004] The purpose of the embodiments of the present application is to provide a table data deletion method, apparatus, computer device, and storage medium to solve the technical problems of low deletion efficiency and long running time in the prior art.

[0005] In order to solve the above technical problems, the present application provides a method for deleting table data, which adopts the following technical solutions:

[0006] A method for deleting table data includes the following steps:

[0007] Find the unique identifier of each row of data in the table to be deleted in the database through multiple threads according to the search code;

[0008] sorting the plurality of unique identifiers according to a preset rule to form a plurality of data sets;

[0009] storing the sorted plurality of data sets into a preset array variable; and

[0010] The deletion operation is performed on the data to be deleted in batches and multiple threads according to the array variables.

[0011] Furthermore, the step of searching for a unique identifier for each row of data in the table to be deleted in a database using multiple threads according to the search code specifically includes:

[0012] Predefine a script file, wherein the script file is used to dynamically create and execute search code;

[0013] Dynamically create a search code in the anonymous block according to the table data to be deleted, and dynamically search for a unique identifier for each row of data in the table data to be deleted in a multi-threaded manner according to the search code;

[0014] The unique identifiers found are stored separately according to the number of threads.

[0015] Furthermore, the step of storing the searched unique identifiers separately according to the number of threads is specifically as follows: dividing the storage units according to the number of threads, and storing the unique identifier searched for each thread in the corresponding storage unit within a unit time.

[0016] Furthermore, the step of sorting the multiple unique identifiers according to a preset rule to form multiple data sets specifically includes:

[0017] identifying the number of threads in the multithreaded search;

[0018] Sort the multiple unique identifiers found in each thread according to preset rules to form multiple data sets; and

[0019] The unique identifiers with inconsistent data object numbers were eliminated to obtain multiple corrected data sets.

[0020] Furthermore, the step of storing the sorted data sets into a preset array variable specifically includes:

[0021] Predefine an array variable, the array variable including a data type, an array name, and a numeric constant expression, the data type being table data, the array name being the name of the data set, and the numeric constant expression representing the size of the array;

[0022] Assign the sorted multiple data sets to the predefined array variable.

[0023] Furthermore, the step of performing the deletion operation on the data to be deleted in batches and multiple threads according to the array variables specifically includes:

[0024] Preset the number of batches and threads to delete;

[0025] The multiple data sets in the array variable are divided into batches, and a multi-threaded deletion operation is performed on each divided data set according to the number of threads.

[0026] Furthermore, the step of dividing the multiple data sets in the array variable into batches and performing a multi-threaded deletion operation on each divided data set according to the number of threads specifically includes:

[0027] Counting the number of unique identifiers with consistent block numbers in the data set;

[0028] The unique identifiers with consistent block numbers are merged, and a multi-threaded deletion operation is performed on the data to be deleted according to the number of threads based on the block numbers.

[0029] In order to solve the above technical problems, the embodiment of the present application further provides a table data deletion device, which adopts the following technical solution:

[0030] A table data deletion device, comprising:

[0031] A search module is used to search the database for a unique identifier for each row of data in the table to be deleted using multiple threads according to the search code;

[0032] a sorting module, configured to sort the plurality of unique identifiers according to preset rules to form a plurality of data sets;

[0033] a pre-storage module, configured to store the sorted plurality of data sets into a preset array variable; and

[0034] The operation module is used to perform a deletion operation on the data to be deleted in batches and multiple threads according to the array variables.

[0035] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:

[0036] A computer device includes a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the table data deletion method as described above when executing the computer-readable instructions.

[0037] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:

[0038] A computer-readable storage medium is characterized in that computer-readable instructions are stored on the computer-readable storage medium, and when the computer-readable instructions are executed by a processor, the steps of the table data deletion method as described above are implemented.

[0039] Compared with the prior art, the embodiments of the present application mainly have the following beneficial effects: the present invention searches for the unique identifier of each row of data in the table data to be deleted in the database in multiple threads according to the search code, sorts the multiple unique identifiers according to preset rules to form multiple data sets, stores the sorted multiple data sets in a preset array variable, and performs deletion operations on the data to be deleted in batches and multiple threads according to the array variables. Since the data in the table data is stored in blocks, the data is identified by the unique identifier of each record in the table data, which can realize block deletion of table data, reduce logical read operations, and at the same time, improve the deletion efficiency and reduce the running time through batch and multi-thread operations. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the solutions in this application, a brief introduction will be given below to the drawings required for use in the description of the embodiments of this application. Obviously, the drawings described below are some embodiments of this application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0041] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;

[0042] Figure 2 A flowchart of an embodiment of a table data deletion method according to the present application;

[0043] Figure 3 yes Figure 2 A flowchart of a specific implementation of step S201;

[0044] Figure 4 yes Figure 2 A flowchart of a specific implementation of step S202;

[0045] Figure 5 yes Figure 2 A flowchart of a specific implementation of step S203;

[0046] Figure 6 yes Figure 2 A flowchart of a specific implementation of step S204;

[0047] Figure 7 This is a structural diagram of an embodiment of a table data deletion device according to the present application;

[0048] Figure 8 yes Figure 7 A schematic structural diagram of a specific implementation of the search module shown;

[0049] Figure 9 yes Figure 7 A schematic structural diagram of a specific implementation of the sorting module shown;

[0050] Figure 10 yes Figure 7 A schematic structural diagram of a specific implementation of the pre-stored module shown;

[0051] Figure 11 yes Figure 7 A structural diagram of a specific implementation of the operation module shown;

[0052] Figure 12 It is a structural diagram of an embodiment of a computer device according to the present application. DETAILED DESCRIPTION

[0053] Unless otherwise defined, all technical and scientific terms used herein have the same meanings as commonly understood by those skilled in the art to which this application belongs. The terms used in the specification of the application are for the purpose of describing specific embodiments only and are not intended to limit this application. The terms "including" and "having" and any variations thereof in the specification and claims of this application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of this application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.

[0054] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0055] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.

[0056] like Figure 1 As shown, system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. Network 104 is a medium for providing communication links between terminal devices 101, 102, 103 and server 105. Network 104 may include various connection types, such as wired or wireless communication links or fiber optic cables.

[0057] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, and 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0058] Terminal devices 101, 102, and 103 can be various electronic devices with display screens and support web browsing, including but not limited to smartphones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 (Moving Picture Experts Group Audio Layer IV), laptop computers, desktop computers, etc.

[0059] The server 105 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal devices 101 , 102 , and 103 .

[0060] It should be noted that the table data deletion method provided in the embodiment of the present application is generally executed by a server, and accordingly, the table data deletion device is generally provided in a terminal device.

[0061] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is merely illustrative. Any number of terminal devices, networks and servers may be provided as required.

[0062] Continue to refer Figure 2 , shows a flow chart of an embodiment of a method for deleting table data according to the present application. The table data deletion method includes the following steps:

[0063] Step S201, searching the database for a unique identifier for each row of data in the table to be deleted using multiple threads according to the search code;

[0064] In this embodiment, because data is stored in blocks in a relational data management system (Oracle), referred to as table data, each row of data in each table has a unique identifier, also known as a rowid. The unique identifier in this embodiment includes a data object number, a corresponding file number, a block number, and a row number. The data object number indicates the number of the database object to which the row belongs, the corresponding file number indicates the number of the file containing the row, the block number indicates the block location of the file containing the row, and the row number indicates the specific location of the row in the row directory. These numbers can be used to uniquely identify the location of each row of data in the database.

[0065] Generally, for the same database, the data object number of each row is consistent, but the corresponding file number, block number, and row number are inconsistent.

[0066] Specifically, such as Figure 3 As shown, step S201 may include the following steps:

[0067] Step S2010: predefine a script file, wherein the script file is used to dynamically create and execute the search code.

[0068] Since the search code needs to be continuously executed when searching, in order to save controls and avoid storing a large amount of code data, a script file (also called an anonymous block) is created.

[0069] Step S2011 , dynamically creating a search code in the anonymous block according to the table data to be deleted, and dynamically searching for a unique identifier for each row of data in the table data to be deleted using multiple threads according to the search code.

[0070] The search code can be executed through the SQL statement. According to the data in the table to be deleted, the SQL search code is dynamically created in the anonymous block by row. After creating a search code, a search code is executed to find the unique identifier of each row of data.

[0071] Specifically, you can increase the number of concurrent connections in the search code and use multiple threads to search for a unique identifier, making it easier and faster to find the unique identifier for each row of data. The number of concurrent connections and threads can be set as needed. For example, you can add / *+parallel4* / to the SQL query code to implement a multi-threaded search, where "4" represents the number of concurrent connections.

[0072] Step S2012: The searched unique identifiers are stored separately according to the number of threads.

[0073] Since the search is performed using multiple threads, after the search, the unique identifiers found need to be stored separately according to the corresponding threads. This step S2012 can be specifically embodied as follows:

[0074] The storage units are divided according to the number of threads, and the unique identifier searched for each thread within a unit of time is stored in the corresponding storage unit.

[0075] Since each thread corresponds to a storage unit, the unique identifier found per unit time in the thread is stored in the storage unit, and each storage unit is stored in chronological order to facilitate subsequent calling and processing.

[0076] In this embodiment, the electronic device (eg Figure 1 The server shown in FIG. 1 may receive the search code information sent by the terminal device via a wired connection or a wireless connection. It should be noted that the wireless connection may include, but is not limited to, 3G / 4G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or to be developed in the future.

[0077] Step S202: sort the multiple unique identifiers according to a preset rule to form multiple data sets.

[0078] In this embodiment, since data is stored in blocks, to facilitate subsequent data deletion, the multiple unique identifiers found need to be sorted. This allows deletion operations to be performed on a block-by-block basis, significantly reducing logical read operations and improving efficiency. Multiple unique identifiers are grouped together and sorted using pre-set rules.

[0079] Specifically, such as Figure 4 As shown, step S201 may include the following steps:

[0080] Step S2011, identifying the number of threads in the multi-threaded search.

[0081] Specifically, the number of threads in the multi-threaded search process is identified, that is, the concurrency number in the SQL code call, such as "4" in step S12.

[0082] Step S2012: sort the multiple unique identifiers found in each thread according to a preset rule to form multiple data sets.

[0083] Specifically, because the unique identifier search process uses multiple threads, the multiple unique identifiers found are not arranged in order. For example, they are sorted from smallest to largest row number in the unique identifier. After the sorting is completed, multiple data sets are formed (i.e., one thread corresponds to one permutation array).

[0084] Among them, the preset rule is the incremental sorting rule. In actual use, the incremental sorting rule can be selected for sorting, such as insertion sort and selection sort.

[0085] Step S2013 , eliminating unique identifiers with inconsistent data object numbers to obtain multiple corrected data sets.

[0086] Specifically, in order to avoid citing erroneous data, the data set needs to be corrected to delete the unique identifier with inconsistent data object number, because the data corresponding to the unique identifier is not the database object to be deleted.

[0087] Step S203: storing the sorted data sets into a preset array variable.

[0088] In this embodiment, multiple unique identifiers form multiple data sets according to the number of threads, and the data sets can be stored in a preset array variable so that the array variable can be called when a delete operation is performed subsequently.

[0089] Specifically, such as Figure 5 As shown, step S203 may include the following steps:

[0090] Step S2031, predefine an array variable, the array variable includes a data type, an array name and a numeric constant expression, the data type is table data, the array name is the name of the data set, and the numeric constant expression represents the size of the array.

[0091] To allocate appropriate memory, you need to predefine an array variable. The array variable includes the data type, array name, and a numeric constant expression. The size of the array is consistent with the number of concurrent connections.

[0092] Step S2032: assign the sorted data sets to the predefined array variable.

[0093] Among them, it can be set to 4 according to the size of the array, and the 4 data sets can be assigned to the array variable.

[0094] Step S204 , performing a deletion operation on the data to be deleted in batches and in multiple threads according to the array variables.

[0095] In this embodiment, when performing a delete operation, the data to be deleted is deleted in batches and through multiple threads based on the data object number, corresponding file number, block number, and row number of the dataset within the array variable. Because the unique identifier includes the data object number, corresponding file number, block number, and row number, and the dataset has been corrected in step S23, the unique identifier with an inconsistent data object number is deleted.

[0096] Specifically, such as Figure 6 As shown, step S204 may include the following steps:

[0097] Step S2041, preset the batches to be deleted and the number of threads.

[0098] Specifically, the number of deletion batches and threads can be preset. For example, the deletion can be divided into 2 batches, and each batch is deleted by 4 threads, which greatly improves the deletion efficiency.

[0099] Step S2042: divide the multiple data sets in the array variable into batches, and perform a multi-threaded deletion operation on each divided data set according to the number of threads. The specific implementation steps of this step are:

[0100] First, the number of unique identifiers with consistent block numbers in the data set is counted.

[0101] Since data is stored in blocks, the block can be deleted as long as the corresponding block number is found. However, since each block of data may contain multiple rows of data, it is necessary to find the unique identifier with the same block number.

[0102] Then, the unique identifiers with the same block numbers are merged, and a multi-threaded deletion operation is performed on the data to be deleted according to the number of threads based on the block numbers. That is, only the unique identifiers need to be merged, and the deletion operation can be performed while retaining the block numbers.

[0103] The present application uses a multi-threaded search in a database based on a search code to find a unique identifier for each row of data in the table data to be deleted, sorts multiple unique identifiers according to preset rules to form multiple data sets, stores the sorted multiple data sets in a preset array variable, and performs deletion operations on the data to be deleted in batches and multiple threads according to the array variable. Since the data in the table data is stored in blocks, the data can be identified by the unique identifier of each record in the table data, which can realize block deletion of table data, reduce logical read operations, and at the same time improve deletion efficiency and reduce running time through batch and multi-thread operations.

[0104] Those skilled in the art will appreciate that all or part of the processes in the above-described method embodiments can be implemented by instructing related hardware via computer-readable instructions. The computer-readable instructions can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes in the above-described method embodiments. The aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0105] It should be understood that although the steps in the flowcharts of the accompanying drawings are shown in sequence as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the flowcharts of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.

[0106] Further references Figure 7 , as a response to the above Figure 2 In order to realize the method shown in FIG, the present application provides an embodiment of a table data deletion device. The embodiment of the device is similar to Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0107] like Figure 7 As shown, the table data deletion device 700 of this embodiment includes: a search module 701, a sorting module 702, a pre-storage module 703 and an operation module 704. Among them:

[0108] A search module 701 is used to search the database for a unique identifier for each row of data in the table to be deleted using multiple threads according to the search code;

[0109] A sorting module 702 is configured to sort the plurality of unique identifiers according to a preset rule to form a plurality of data sets;

[0110] A pre-storage module 703 is used to store the sorted data sets into a preset array variable;

[0111] The operation module 704 is used to perform a deletion operation on the data to be deleted in batches and multiple threads according to the array variables.

[0112] The search module 701 of the present application searches for the unique identifier of each row of data in the table data to be deleted in the database through multi-threading according to the search code, the sorting module 702 sorts the multiple unique identifiers according to preset rules to form multiple data sets, the pre-storage module 703 stores the sorted multiple data sets into a preset array variable, and the operation module 704 performs the deletion operation on the data to be deleted in batches and multi-threading according to the array variable. Since the data in the table data is stored in blocks, the data can be identified by the unique identifier of each record in the table data, which can realize block deletion of table data, reducing the operation of logical reads. At the same time, through batch and multi-threaded operations, the deletion efficiency is improved and the running time is reduced.

[0113] See Figure 8 , is a schematic diagram of a specific implementation of search module 701. Search module 701 includes a first pre-defined sub-module 7011, a dynamic creation and search sub-module 7012, and a storage sub-module 7013. First pre-defined sub-module 7011 is used to pre-define a script file for dynamically creating and executing search code; dynamic creation and search sub-module 7012 is used to dynamically create a search code within the anonymous block based on the data in the table to be deleted, and dynamically use the search code to perform a multi-threaded search to determine the unique identifier for each row of data in the table to be deleted; and storage sub-module 7013 is used to store the searched unique identifiers separately according to the number of threads.

[0114] See Figure 9 , is a schematic diagram of a specific implementation of sorting module 702. Sorting module 702 includes an identification submodule 7021, a sorting submodule 7022, and a correction submodule 7023. Identification submodule 7021 is used to identify the number of threads in the multi-threaded search; sorting submodule 7022 is used to sort the multiple unique identifiers found in each thread according to preset rules to form multiple data sets; and correction submodule 7023 is used to correct the multiple data sets to eliminate unique identifiers with inconsistent data object numbers.

[0115] See Figure 10 , is a schematic diagram of a specific implementation of pre-storage module 703. Pre-storage module 703 includes a second pre-definition sub-module 7031 and an assignment sub-module 7032. Second pre-definition sub-module 7031 is used to pre-define an array variable, which includes a data type, an array name, and a numeric constant expression. The data type is table data, the array name is the name of the dataset, and the numeric constant expression represents the size of the array. Assignment sub-module 7032 is used to assign the sorted multiple datasets to the pre-defined array variable.

[0116] See Figure 11 , is a schematic diagram of a specific implementation of the operation module 704. The operation module 704 includes a preset submodule 7041 and a segmentation and deletion module 7042. The preset submodule 7041 is used to preset the batches to be deleted and the number of threads; the segmentation and deletion module 7042 is used to segment the multiple data sets in the array variable into batches and perform a multi-threaded deletion operation on each segmented data set according to the number of threads.

[0117] In some optional implementations of this embodiment, the segmentation and deletion module 7042 includes: a statistical unit for counting the number of unique identifiers with consistent block numbers in the data set; a merging unit for merging the unique identifiers with consistent block numbers; and a deletion unit for performing multi-threaded deletion operations on the data to be deleted according to the number of threads based on the block number.

[0118] To solve the above technical problems, the present application also provides a computer device. Figure 12 , Figure 12 This is a basic structural block diagram of the computer device in this embodiment.

[0119] The computer device 12 includes a memory 121, a processor 122, and a network interface 123 that are interconnected through a system bus. It should be noted that the figure only shows a computer device 12 with components 121-123, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.

[0120] The computer device may be a desktop computer, notebook computer, PDA, cloud server, etc. The computer device may interact with the user via a keyboard, mouse, remote control, touchpad, or voice control device.

[0121] The memory 121 includes at least one type of readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 121 can be an internal storage unit of the computer device 6, such as the hard disk or memory of the computer device 12. In other embodiments, the memory 121 can also be an external storage device of the computer device 12, such as a plug-in hard disk equipped on the computer device 12, a smart memory card (SMC), a secure digital (SD) card, a flash memory card, etc. Of course, the memory 121 can also include both the internal storage unit of the computer device 12 and its external storage device. In this embodiment, the memory 121 is generally used to store the operating system and various application software installed on the computer device 12, such as computer-readable instructions for the table data deletion method. In addition, the memory 121 can also be used to temporarily store various types of data that have been output or are to be output.

[0122] In some embodiments, the processor 122 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip. The processor 122 is generally used to control the overall operation of the computer device 12. In this embodiment, the processor 122 is used to execute computer-readable instructions stored in the memory 121 or process data, such as computer-readable instructions for executing the table data deletion method.

[0123] The network interface 123 may include a wireless network interface or a wired network interface. The network interface 123 is generally used to establish a communication connection between the computer device 12 and other electronic devices.

[0124] The present application uses a multi-threaded search in a database based on a search code to find a unique identifier for each row of data in the table data to be deleted, sorts multiple unique identifiers according to preset rules to form multiple data sets, stores the sorted multiple data sets in a preset array variable, and performs deletion operations on the data to be deleted in batches and multiple threads according to the array variable. Since the data in the table data is stored in blocks, the data can be identified by the unique identifier of each record in the table data, which can realize block deletion of table data, reduce logical read operations, and at the same time improve deletion efficiency and reduce running time through batch and multi-thread operations.

[0125] The present application also provides another embodiment, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the table data deletion method as described above.

[0126] The present application uses a multi-threaded search in a database based on a search code to find a unique identifier for each row of data in the table data to be deleted, sorts multiple unique identifiers according to preset rules to form multiple data sets, stores the sorted multiple data sets in a preset array variable, and performs deletion operations on the data to be deleted in batches and multiple threads according to the array variable. Since the data in the table data is stored in blocks, the data can be identified by the unique identifier of each record in the table data, which can realize block deletion of table data, reduce logical read operations, and at the same time improve deletion efficiency and reduce running time through batch and multi-thread operations.

[0127] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0128] Obviously, the embodiments described above are only some of the embodiments of the present application, rather than all of the embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application has been described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions described in the aforementioned specific embodiments, or to make equivalent replacements for some of the technical features therein. Any equivalent structure made using the contents of the present application specification and the accompanying drawings, directly or indirectly used in other related technical fields, is also within the scope of patent protection of the present application.

Claims

1. A table data deletion method, characterized in that: The steps include: Finding a unique identifier for each row of data in the table data to be deleted in a database using multiple threads according to the search code, wherein the unique identifier includes a data object number, a corresponding file number, a block number, and a row number in order according to a storage hierarchy. Specifically, the data object number indicates the database object number to which the target row of data belongs, the corresponding file number indicates the number of the file in the database where the target row of data is stored, the block number indicates the number of the storage block to which the target row of data belongs in the storage file, and the row number indicates the row number of the target row of data in the storage block; Sorting the plurality of unique identifiers according to a preset rule to form a plurality of data sets, wherein the plurality of unique identifiers form a data set of the number of threads according to the number of threads for searching multithreading; storing the sorted data sets into a preset array variable, wherein each array variable name corresponds to the name of a data set; and The step of performing the deletion operation on the data to be deleted in batches and in multiple threads according to the array variables specifically includes: Preset the number of batches and threads to delete; The plurality of data sets in the array variable are divided into batches, and a multi-threaded deletion operation is performed on each divided data set according to the number of threads. Specifically, the ... steps of dividing the plurality of data sets in the array variable into batches and performing a multi-threaded deletion operation on each divided data set according to the number of threads include: Counting the number of unique identifiers with consistent block numbers in the data set; The unique identifiers with consistent block numbers are merged, and a multi-threaded deletion operation is performed on the data to be deleted according to the number of threads based on the block numbers.

2. The table data deletion method according to claim 1, characterized in that: The step of searching for the unique identifier of each row of data in the table to be deleted in a database using multiple threads according to the search code specifically includes: Predefine a script file, wherein the script file is used to dynamically create and execute search code; Dynamically create a search code in the script file according to the table data to be deleted, and dynamically search for a unique identifier for each row of data in the table data to be deleted in a multi-threaded manner according to the search code; The unique identifiers found are stored separately according to the number of threads.

3. The table data deletion method according to claim 2, characterized in that: The step of storing the unique identifiers found according to the number of threads is specifically as follows: The storage units are divided according to the number of threads, and the unique identifier searched for each thread within a unit of time is stored in the corresponding storage unit.

4. The table data deletion method according to claim 1, characterized in that: The step of sorting the plurality of unique identifiers according to a preset rule to form a plurality of data sets specifically includes: identifying the number of threads in the multithreaded search; Sort the multiple unique identifiers found in each thread according to preset rules to form multiple data sets; and The unique identifiers with inconsistent data object numbers were eliminated to obtain multiple corrected data sets.

5. The table data deletion method according to claim 1, characterized in that: The step of storing the sorted plurality of data sets into a preset array variable specifically includes: Predefine an array variable, the array variable including a data type, an array name, and a numeric constant expression, the data type being table data, the array name being the name of the data set, and the numeric constant expression representing the size of the array; Assign the sorted multiple data sets to the predefined array variable.

6. A table data deletion device, characterized in that: The table data deletion device is used to implement the steps of the table data deletion method according to any one of claims 1 to 5, and the table data deletion device includes: A search module is used to search the database for a unique identifier for each row of data in the table to be deleted using multiple threads according to the search code; a sorting module, configured to sort the plurality of unique identifiers according to a preset rule to form a plurality of data sets, wherein the plurality of unique identifiers form a data set of the number of threads according to the number of threads for searching the multithreaded image; a pre-storage module, configured to store the sorted plurality of data sets into a preset array variable, wherein each array variable name corresponds to a name of a data set; and The operation module is used to perform a deletion operation on the data to be deleted in batches and multiple threads according to the array variables.

7. A computer device comprising a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the table data deletion method according to any one of claims 1 to 5 when executing the computer-readable instructions.

8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the table data deletion method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Message data extraction method and device

    CN112511643A

  • Data processing method and device, equipment and storage medium

    CN112765169A