Unique index implementation method and device, equipment and storage medium

By retrieving and overwriting physical records of unique index key values ​​when inserting operations in the database, the problem of unique index key values ​​in the prior art is solved, and the efficiency of DML operations and the uniqueness of indexes are improved.

CN119322779APending Publication Date: 2025-01-17SHANGHAI DAMENG DATABASE
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411436197.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-15
Publication Date
2025-01-17

AI Technical Summary

Technical Problem

In the prior art, the unique index key value is not truly unique, resulting in low efficiency in the execution of DML operations in the database.

Method used

During the insertion operation, by obtaining the key value of the record to be inserted, searching for whether there is a physical record of the same key value in the data table, and making a visibility judgment. If the physical record is visible and there is a delete mark, the record to be inserted is overwritten to the Position, ensure uniqueness of index key values.

Benefits of technology

It improves the execution efficiency of DML operations, solves the inefficiency problem caused by the inequality of unique index key values, reduces the number of checks on the same key value records, and reduces the risk of storage space occupation and B-tree splitting.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119322779A_ABST
    Figure CN119322779A_ABST
Patent Text Reader

Abstract

The invention discloses a unique index implementation method and device, equipment and a storage medium. The method comprises the following steps: when an insertion operation comprises modification of a unique index in a data table, obtaining a key value to be inserted and recorded on the unique index; retrieving whether a physical record of which the key value of the unique index is the same as the key value of the to-be-inserted record exists in the data table or not; if yes, carrying out visibility judgment on the physical record; and if the physical record is visible and the deletion mark exists, covering the to-be-inserted record to the position of the physical record. According to the method, when the insertion operation is carried out, the physical record with the same key value as the to-be-inserted record is found through the key value of the unique index in the data table, and when the physical record is visible and has the deletion mark, the to-be-inserted record directly covers the position of the physical record, so that the unique index key value in the data table can be really unique; and the execution efficiency of the DML operation is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the technical field of database management, and in particular to a unique index implementation method, device, equipment and storage medium. Background Art

[0002] Multi-Version Concurrency Control (MVCC) is a concurrency control method that is generally used to implement concurrent access to databases in database management systems and to implement transactional memory in programming languages. MVCC can maintain historical version data at the row level through rollback records, and only the latest data is retained on the clustered index to which the table belongs. In a database management system, when creating a table, you can specify a clustered primary key (Cluster Key) to create an ordered index, and the physical records on the index are stored in order according to the specified key value. However, an ordered index does not guarantee the uniqueness of the key value of the physical record, but only guarantees that the key value of the physical record is ordered. There may be multiple records with the same key value on the index at the same time. Therefore, when creating a table, you can specify a clustered primary key (Cluster Primary Key) or a clustered unique key (Cluster Unique Key) to create a unique index. The unique index can ensure the uniqueness of data records.

[0003] However, in the prior art, unique indexes are implemented by adjusting the execution process of insert operations through MVCC, thereby ensuring the uniqueness of the record key values ​​in the query results. However, the uniqueness of the physical record key values ​​on the index is not truly guaranteed, which leads to the problem of low efficiency when executing the data manipulation language (DML) operations of the database. Summary of the invention

[0004] The present invention provides a unique index implementation method, device, equipment and storage medium to solve the problem in the prior art that the unique index key value is not truly unique, thereby resulting in low efficiency in DML operation execution.

[0005] According to one aspect of the present invention, a unique index implementation method is provided, the method comprising:

[0006] When the insert operation includes modifying the unique index in the data table, obtain the key value of the record to be inserted on the unique index;

[0007] Searching the data table for a physical record having a unique index key value identical to the key value of the record to be inserted;

[0008] If so, performing visibility determination on the physical record;

[0009] If the physical record is visible and has a deletion mark, the record to be inserted is overwritten to the position of the physical record.

[0010] According to another aspect of the present invention, a unique index implementation device is provided, the device comprising:

[0011] An acquisition module, used for acquiring the key value of the record to be inserted on the unique index when the insert operation includes modifying the unique index in the data table;

[0012] A determination module, used for searching whether there is a physical record in the data table whose key value of the unique index is the same as the key value of the record to be inserted;

[0013] A judgment module, configured to judge the visibility of the physical record if yes;

[0014] The storage module is used for overwriting the record to be inserted to the position of the physical record if the physical record is visible and has a deletion mark.

[0015] According to another aspect of the present invention, there is provided an electronic device, the electronic device comprising: at least one processor; and

[0016] a memory communicatively connected to the at least one processor; wherein,

[0017] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the unique index implementation method described in any embodiment of the present invention.

[0018] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the unique index implementation method described in any embodiment of the present invention when executed.

[0019] A unique index implementation method, device, equipment and storage medium according to an embodiment of the present invention, the method includes: when an insert operation includes modifying a unique index in a data table, obtaining a key value of a record to be inserted on the unique index; searching the data table for a physical record whose key value of the unique index is the same as the key value of the record to be inserted; if so, making a visibility judgment on the physical record; if the physical record is visible and has a deletion mark, overwriting the record to be inserted to the position of the physical record. This method can ensure that the key value of the unique index in the data table is truly unique by finding the physical record with the same key value as the record to be inserted through the key value of the unique index in the data table during an insert operation, and directly overwriting the record to be inserted to the position of the physical record when the physical record is visible and has a deletion mark, thereby improving the execution efficiency of DML operations and solving the problem in the prior art that the unique index key value is not truly unique, thereby resulting in low execution efficiency of DML operations.

[0020] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0022] Figure 1 A schematic diagram of the relationship between the physical records stored in the data table and the corresponding rollback records in the prior art;

[0023] Figure 2 A flowchart of a unique index implementation method provided in the first embodiment of the present invention;

[0024] Figure 3 A schematic diagram of the structure of a unique index implementation device provided in Embodiment 2 of the present invention;

[0025] Figure 4 Schematic diagram of the structure of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0026] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiment of the present invention. Obviously, the described embodiment is only an embodiment of a part of the present invention, rather than all the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work should belong to the scope of protection of the present invention. It should be understood that the various steps recorded in the method implementation of the present invention can be performed in different orders and / or in parallel. In addition, the method implementation may include additional steps and / or omit the steps shown. The scope of the present invention is not limited in this respect.

[0027] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

[0028] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, any variations of the terms "including" and "having" are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0029] It should be noted that the modifications of "one" and "plurality" mentioned in the present invention are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0030] The names of the messages or information exchanged between multiple devices in the embodiments of the present invention are only used for illustrative purposes, and are not used to limit the scope of these messages or information.

[0031] Figure 1 FIG. 1 is a schematic diagram showing the relationship between the physical records stored in the data table and the corresponding rollback records in the prior art. Figure 1As shown in the figure, each time the data in the table is updated, the physical record saves the latest data of the clustered index, and a rollback record is generated to save the physical record before the update. The TID (title_id) field represents the transaction ID (Identity) of the updated data, the ROWID field is the row number automatically generated when the data is inserted, and the RPTR (Read Pointer) field points to the associated rollback record. Multiple rollback records are organized into a one-way linked list.

[0032] When creating a table, specify the Cluster Key to create an ordered index. The physical records on the index are stored in order according to the specified key value. As shown in the following Structured Query Language (SQL), an ordered table test1 is created, column a is the clustering key, and the physical records are sorted according to the value of column a (i.e., the clustering key value) when inserting data. Column b is a non-clustered column, and updating column b does not involve changing the key value.

[0033] CREATE TABLE test1(a INT,b VARCHAR,CLUSTER KEY(a));

[0034] DML operations include insert (INSERT), update (UPDATE) and delete (DELETE). Compared with ordinary indexes, the DELETE operation on ordered indexes is the same as that on ordinary indexes. When performing a delete operation, a delete mark is set on the physical record and a rollback record is generated. The INSERT operation on an ordered index is similar to that on an ordinary index, except that the physical records after the INSERT operation need to be sorted according to the key value, and the physical records are inserted in order on the index. For the UPDATE operation on an ordered index, if the update operation does not involve a key value change, it is the same as an ordinary index, updating the physical record and generating a rollback record; if the update of the physical record causes a key value change, the physical record needs to be "moved" to the new location, which is internally implemented as independent DELETE and INSERT operations, that is, the physical record is first deleted from the old location and inserted into the new location.

[0035] To implement a unique index, specify Cluster Primary Key or Cluster Unique Key when creating a table. As shown in the following SQL statement, a unique table test2 is created, column c is the clustering key, and physical records are sorted according to the value of column c when inserting data, and the value of column c is globally unique. Column d is a non-clustered column, and updating column d does not involve changing the key value.

[0036] CREATE TABLE test2(c INT,d VARCHAR,CLUSTER UNIQUE KEY(c));

[0037] The DELETE and UPDATE operations of a unique index are the same as those of an ordered index, with only the INSERT operation being different: when executing an INSERT, first search the index to see if there is a physical record with the same key value. If not, the new physical record can be directly inserted in order; if it does, continue with the subsequent steps to determine the visibility of the record. If the record is not visible (that is, the record is a newly inserted or deleted record), it means that there is an uncommitted transaction. Get the ROWID of the physical record and block it, and wait for the concurrent transaction to complete (commit or rollback) before retrying the insertion operation. If the record is visible and the delete mark is not set on the record, a record with the same key value already exists, and an error is returned. If the record is visible and the delete mark is set, continue to retrieve the next physical record with the same key value and continue to determine visibility.

[0038] However, the unique index established above, on the one hand, needs to check multiple physical records with the same key value to determine whether the insert operation can be performed when inserting a new physical record, which reduces the efficiency of the insert operation; on the other hand, when there are frequent DML operations on the table involving the same key value, multiple physical records with the same key value will be stored on the index, occupying more storage space, and more likely to trigger the split of the B-tree, and the efficiency of the DML operation will also decrease. Therefore, this embodiment provides a unique index implementation method to solve the above problems.

[0039] Embodiment 1

[0040] Figure 2 A flow chart of a unique index implementation method provided in Embodiment 1 of the present invention is provided. The method can be applied to the case where a unique index key value in a data table is ensured to be truly unique when performing DML operations on records in the data table. The method can be executed by a unique index implementation device, wherein the device can be implemented by software and / or hardware and is generally integrated on an electronic device. In this embodiment, the electronic device includes but is not limited to: computers and other devices.

[0041] like Figure 2 As shown, a unique index implementation method provided in Embodiment 1 of the present invention includes the following steps:

[0042] S110: When the insert operation includes modifying a unique index in the data table, obtain a key value of the record to be inserted on the unique index.

[0043] Among them, the insert operation can be an operation of inserting a data row into a database table. The insert operation in this embodiment refers to an operation implemented inside the database. A unique index can be established in the data table, such as test2 as described above. The physical record in the data table can record information such as row number ROWID, transaction identifier TID, rollback record address RPTR, latest data, etc. The column where the unique index is located can be a column that can identify different data in the data table. The record to be inserted can be a record that needs to be inserted.

[0044] In this embodiment, when the DML operation is an INSERT or UPDATE operation, an insert operation will be triggered in the database. If the insert operation involves modifying the unique index in the data table, it is necessary to compare whether the unique index key value to be modified already exists in the data table, and then the key value of the record to be inserted on the unique index can be obtained.

[0045] S120, searching the data table for a physical record whose unique index key value is the same as the key value of the record to be inserted.

[0046] Wherein, the physical record may be each record in the data table;

[0047] In this embodiment, all physical records in the data table can be searched to confirm whether there is a physical record whose key value of the unique index is the same as the key value of the record to be inserted. If not, the record to be inserted can be directly inserted in order.

[0048] S130: If yes, determine the visibility of the physical record.

[0049] The visibility judgment refers to the need to determine, for a specific record, whether the record is visible to the current pending transaction (ie, insert operation) based on the state of the transaction corresponding to the record.

[0050] In this embodiment, if there is a physical record in the data table with the same key value as the record to be inserted, the visibility of the physical record needs to be determined. If the physical record is not visible, it means that there is an uncommitted transaction. At this time, the ROWID of the physical record can be obtained and blocked, and the insertion operation can be retried after the concurrent transaction is completed (committed or rolled back).

[0051] S140: If the physical record is visible and has a deletion mark, overwrite the record to be inserted to the position of the physical record.

[0052] Among them, the deletion mark can be used to indicate that the record has been deleted.

[0053] In this embodiment, if the physical record is visible and has a deletion mark, it means that the physical record has been deleted. Then the record to be inserted can be used to overwrite the old physical record. By overwriting the records, the uniqueness of the unique key value of the physical record can be guaranteed.

[0054] In one embodiment, when the record to be inserted is overwritten and stored at the location of the physical record, the method further includes: generating a rollback record for the physical record, and marking the rollback record type as a record deleted type.

[0055] The rollback record may be a historical modification version of a physical record. The rollback record type is a deleted type, indicating that the rollback record is a deleted record.

[0056] In this embodiment, while the record to be inserted is used to overwrite the old physical record, a new rollback record type UNDO_UPD_INS may be generated to save the old physical record.

[0057] This embodiment reduces the number of checks for records with the same key value by ensuring the uniqueness of the unique index within the data table, thereby improving the execution efficiency of the insert operation; at the same time, the newly added rollback record type UNDO_UPD_INS saves the records before deletion, which can maintain the correctness of multi-version data queries.

[0058] A unique index implementation method provided in a first embodiment of the present invention includes: when an insert operation includes modifying a unique index in a data table, obtaining a key value of a record to be inserted on a unique index; searching the data table for a physical record whose key value of the unique index is the same as the key value of the record to be inserted; if so, making a visibility judgment on the physical record; if the physical record is visible and has a deletion mark, overwriting the record to be inserted to the position of the physical record. This method can ensure that the key value of the unique index in the data table is truly unique by finding the physical record with the same key value as the record to be inserted through the key value of the unique index in the data table during an insert operation, and directly overwriting the record to be inserted to the position of the physical record when the physical record is visible and has a deletion mark, thereby improving the execution efficiency of DML operations and solving the problem in the prior art that the unique index key value is not truly unique, thereby resulting in low execution efficiency of DML operations.

[0059] Based on the above embodiment, a variant embodiment of the above embodiment is proposed. It should be noted that in order to make the description concise, only the differences from the above embodiment are described in the variant embodiment.

[0060] In one embodiment, the visibility judgment of the physical record includes: obtaining the transaction identifier of the physical record, and determining the visibility of the physical record according to the transaction identifier; when the visibility of the physical record is invisible, continuing to judge the visibility according to the rollback record corresponding to the physical record and the rollback record type of the rollback record.

[0061] The transaction identifier may be an identifier of the transaction corresponding to the physical record.

[0062] In this embodiment, when the visibility of the physical record is judged, the transaction identifier of the physical record can be obtained, and the visibility of the physical record can be determined based on the transaction identifier of the physical record. When the visibility of the physical record is invisible, the visibility judgment can be further performed based on the rollback record corresponding to the physical record and the rollback record type of the rollback record, that is, to determine whether there is a visible version of the record in the rollback record corresponding to the physical record.

[0063] It can be understood that the visibility judgment method of this embodiment is not only applicable to the visibility judgment of physical records when performing an insert operation, but can also be used to judge the visibility of physical records when performing a query operation or other operations.

[0064] In one embodiment, the method further comprises: when the visibility of the physical record is visible, returning the visibility as a visibility result.

[0065] The visibility result may be a result of visibility judgment, and the visibility result may include visible and invisible.

[0066] In this embodiment, when the visibility of the physical record is visible, it means that the current transaction can obtain the value of the physical record, and visible can be returned as the visibility result.

[0067] In one embodiment, the visibility judgment is continued based on the rollback record corresponding to the physical record and the rollback record type of the rollback record, including: determining whether there is a corresponding rollback record based on the rollback pointer of the physical record; if so, obtaining the rollback record corresponding to the physical record based on the rollback pointer, and performing a visibility judgment based on the visibility of the rollback record and the rollback record type; otherwise, returning invisible as the visibility result.

[0068] The rollback pointer may be a pointer for indicating the address of the rollback record.

[0069] In this embodiment, the rollback pointer RPTR of the physical record can be used to determine whether the physical record has a corresponding rollback record. If so, the corresponding rollback record can be obtained according to the rollback pointer, and visibility can be determined according to whether the rollback record is visible and the rollback record type. If the corresponding rollback record is not found, invisible is returned as the visibility result.

[0070] In one embodiment, determining whether there is a corresponding rollback record based on the rollback pointer of the physical record includes: determining the rollback record address based on the rollback pointer of the physical record; when the rollback record address is empty, determining that there is no corresponding rollback record for the physical record; when the rollback record address is not empty, determining that there is a corresponding rollback record for the physical record.

[0071] The rollback record address may be a physical address of the rollback record.

[0072] In this embodiment, the rollback record address is obtained according to the rollback pointer. When the rollback record address is NULL, it can be considered that the rollback record is invisible or there is no corresponding rollback record in the physical record. When the rollback record is not NULL, it is considered that there is a corresponding rollback record in the physical record.

[0073] In one embodiment, visibility judgment is performed based on the visibility of the rollback record and the rollback record type, including: if the visibility of the rollback record is visible, and the rollback record type of the rollback record is not a deleted type, visible is returned as a visibility result; if the visibility of the rollback record is visible, and the rollback record type of the rollback record is a deleted type, invisible is returned as a visibility result; if the visibility of the rollback record is invisible, the next rollback record is obtained according to the rollback pointer of the rollback record, and the visibility judgment is continued according to the next rollback record and the rollback record type of the next rollback record.

[0074] In this embodiment, when the rollback record is visible, it is further determined whether the rollback record type is the deleted type UNDO_UPD_INS. If not, visible can be returned as the visibility result; if yes, it means that the rollback record has been deleted with a deletion mark set, and the record is considered invisible, and invisible is returned as the visibility result. If the visibility of the rollback record is invisible, the RPTR field of the rollback record can be obtained, and the next rollback record can be found according to the RPTR field, and the visibility judgment of the next rollback record can be continued until the visibility result is obtained or all rollback records are found.

[0075] Embodiment 2

[0076] Figure 3This is a structural schematic diagram of a unique index implementation device provided in Embodiment 2 of the present invention. The device can be used to ensure that the unique index key value in the data table is truly unique when performing DML operations on records in the data table. The device can be implemented by software and / or hardware and is generally integrated on an electronic device.

[0077] like Figure 3 As shown, the device comprises:

[0078] The acquisition module 210 is used to acquire the key value of the record to be inserted on the unique index when the insert operation includes modifying the unique index in the data table;

[0079] A determination module 220 is used to retrieve whether there is a physical record in the data table whose key value of the unique index is the same as the key value of the record to be inserted;

[0080] A judgment module 230, configured to judge the visibility of the physical record;

[0081] The storage module 240 is configured to overwrite the position of the physical record with the record to be inserted if the physical record is visible and has a deletion mark.

[0082] This embodiment provides a unique index implementation device, the device comprising: an acquisition module, used to acquire the key value of the record to be inserted on the unique index when the insert operation includes the modification of the unique index in the data table; a determination module, used to retrieve whether there is a physical record in the data table whose key value of the unique index is the same as the key value of the record to be inserted; a judgment module, used to make a visibility judgment on the physical record if so; a storage module, used to overwrite the record to be inserted to the position of the physical record if the physical record is visible and has a deletion mark. By finding the physical record with the same key value as the record to be inserted through the key value of the unique index in the data table during the insert operation, and directly overwriting the record to be inserted to the position of the physical record when the physical record is visible and has a deletion mark, it can ensure that the unique index key value in the data table is truly unique, improve the execution efficiency of DML operations, and solve the problem in the prior art that the unique index key value is not truly unique, thereby resulting in low execution efficiency of DML operations.

[0083] Furthermore, the storage module 240 is also used for:

[0084] A rollback record is generated for the physical record, and the rollback record type is marked as a record deleted type.

[0085] Furthermore, the determination module 230 is specifically configured to:

[0086] Acquire a transaction identifier of the physical record, and determine visibility of the physical record according to the transaction identifier;

[0087] When the visibility of the physical record is invisible, visibility judgment is continued according to the rollback record corresponding to the physical record and the rollback record type of the rollback record.

[0088] Furthermore, the device is also used for:

[0089] When the visibility of the physical record is visible, the visible is returned as a visibility result.

[0090] Further, continuing to perform visibility judgment according to the rollback record corresponding to the physical record and the rollback record type of the rollback record includes:

[0091] Determining whether there is a corresponding rollback record according to the rollback pointer of the physical record;

[0092] If so, the rollback record corresponding to the physical record is obtained according to the rollback pointer, and visibility is judged according to the visibility and type of the rollback record; otherwise, invisible is returned as the visibility result.

[0093] Further, the determining whether there is a corresponding rollback record according to the rollback pointer of the physical record includes:

[0094] Determine the rollback record address according to the rollback pointer of the physical record;

[0095] When the rollback record address is empty, determining that the physical record does not have a corresponding rollback record;

[0096] When the rollback record address is not empty, it is determined that a corresponding rollback record exists for the physical record.

[0097] Further, the visibility is judged according to the visibility of the rollback record and the type of the rollback record, including:

[0098] If the visibility of the rollback record is visible, and the rollback record type of the rollback record is not a deleted type, visible is returned as the visibility result;

[0099] If the visibility of the rollback record is visible, and the rollback record type of the rollback record is a deleted type, invisible is returned as the visibility result;

[0100] If the visibility of the rollback record is invisible, the next rollback record is obtained according to the rollback pointer of the rollback record, and the visibility judgment is continued according to the next rollback record and the rollback record type of the next rollback record.

[0101] The above-mentioned unique index implementation device can execute the unique index implementation method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0102] Embodiment 3

[0103] Figure 4 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0104] like Figure 4 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0105] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0106] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a unique index implementation method.

[0107] In some embodiments, the unique index implementation method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the unique index implementation method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the unique index implementation method in any other appropriate manner (e.g., by means of firmware).

[0108] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0109] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0110] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0111] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0112] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0113] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0114] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0115] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A unique index implementation method, characterized in that: The method comprises: When the insert operation includes modifying the unique index in the data table, obtain the key value of the record to be inserted on the unique index; Searching the data table for a physical record having a unique index key value identical to the key value of the record to be inserted; If so, performing visibility determination on the physical record; If the physical record is visible and has a deletion mark, the record to be inserted is overwritten to the position of the physical record.

2. The method according to claim 1, characterized in that When the record to be inserted is overwritten and stored at the location of the physical record, the method further comprises: A rollback record is generated for the physical record, and the rollback record type is marked as a record deleted type.

3. The method according to claim 1, characterized in that The determining the visibility of the physical record includes: Acquire a transaction identifier of the physical record, and determine visibility of the physical record according to the transaction identifier; When the visibility of the physical record is invisible, visibility judgment is continued according to the rollback record corresponding to the physical record and the rollback record type of the rollback record.

4. The method according to claim 3, characterized in that The method further comprises: When the visibility of the physical record is visible, the visible is returned as a visibility result.

5. The method according to claim 3, characterized in that: The continuing to perform visibility judgment according to the rollback record corresponding to the physical record and the rollback record type of the rollback record includes: Determining whether there is a corresponding rollback record according to the rollback pointer of the physical record; If so, the rollback record corresponding to the physical record is obtained according to the rollback pointer, and visibility is judged according to the visibility and type of the rollback record; otherwise, invisible is returned as the visibility result.

6. The method according to claim 5, characterized in that The determining whether a corresponding rollback record exists according to the rollback pointer of the physical record includes: Determine the rollback record address according to the rollback pointer of the physical record; When the rollback record address is empty, determining that the physical record does not have a corresponding rollback record; When the rollback record address is not empty, it is determined that a corresponding rollback record exists for the physical record.

7. The method according to claim 5, characterized in that The visibility judgment is performed according to the visibility of the rollback record and the rollback record type, including: If the visibility of the rollback record is visible, and the rollback record type of the rollback record is not a deleted type, visible is returned as the visibility result; If the visibility of the rollback record is visible, and the rollback record type of the rollback record is a deleted type, invisible is returned as the visibility result; If the visibility of the rollback record is invisible, the next rollback record is obtained according to the rollback pointer of the rollback record, and the visibility judgment is continued according to the next rollback record and the rollback record type of the next rollback record.

8. A unique index implementation device, characterized in that: The device comprises: An acquisition module, used for acquiring the key value of the record to be inserted on the unique index when the insert operation includes modifying the unique index in the data table; A determination module, used for searching whether there is a physical record in the data table whose key value of the unique index is the same as the key value of the record to be inserted; A judgment module, configured to judge the visibility of the physical record if yes; The storage module is used for overwriting the record to be inserted to the position of the physical record if the physical record is visible and has a deletion mark.

9. An electronic device, characterized in that: The device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the unique index implementation method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the unique index implementation method according to any one of claims 1 to 7 when executed.