Row identification generation method, device, equipment, medium and product in database

CN122946401APending Publication Date: 2026-10-20SHANGHAI DAMENG DATABASE
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611349378.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-02
Publication Date
2026-10-20

AI Technical Summary

Technical Problem

[0004]本发明提供了一种数据库中行标识生成方法、装置、设备、介质及产品,以解决向聚集索引中插入新记录时,高并发环境下的并发冲突问题

Benefits of technology

[0010]本发明实施例的技术方案,通过获取索引和所述索引对应的字典对象,所述索引包括待插入数据的表对应的索引,所述字典对象包括所述索引中当前最大的行标识;若所述索引包括主键,则从所述索引的字典对象中,读取第一当前最大行标识,根据所述第一当前最大行标识确定临时变量;判断所述临时变量是否为预设数值的倍数;若所述临时变量不是所述预设数值的倍数,则对所述字典对象中的第二当前最大行标识和所述临时变量执行比较并交换操作,并根据所述临时变量确定行标识结果,所述第二当前最大行标识的读取时间晚于所述第一当前最大行标识,所述比较并交换操作包括根据所述第二当前最大行标识与所述临时变量的数值关系,根据所述临时变量更新所述字典对象的操作,所述行标识结果包括为所述待插入数据分配的行标识;若所述临时变量是预设数值的倍数,则进入临界区,获取所述字典对象中的第三当前最大行标识,根据所述第三当前最大行标识是否为所述预设数值的倍数,基于所述第三当前最大行标识更新所述字典对象和索引控制页,根据所述第三当前最大行标识确定所述行标识结果,退出所述临界区,所述第三当前最大行标识的读取时间晚于所述第一当前最大行标识。本发明实施例的技术方案,通过字典对象包存储索引中当前最大的行标识,避免在高并发场景下多个插入线程频繁对索引控制页进行排他封锁而引起的并发冲突,提升了高并发场景下行标识的并发插入性能,从而提高了数据库整体性能。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure FT_1
    Figure FT_1
  • Figure FT_2
    Figure FT_2
  • Figure FT_3
    Figure FT_3
Patent Text Reader

Abstract

This invention discloses a method, apparatus, device, medium, and product for generating row identifiers in a database. The process involves: obtaining an index and its corresponding dictionary object; if the index includes a primary key, reading the first current maximum row identifier from the dictionary object and determining a temporary variable based on this identifier; determining whether the temporary variable is a multiple of a preset value; if the temporary variable is not a multiple of the preset value, comparing and swapping the second current maximum row identifier in the dictionary object with the temporary variable, and determining the row identifier result based on the temporary variable; if the temporary variable is a multiple of the preset value, entering a critical section to obtain the third current maximum row identifier from the dictionary object; updating the dictionary object and index control page based on the third current maximum row identifier; determining the row identifier result based on the third current maximum row identifier; and exiting the critical section. This avoids frequent exclusive blocking of the index control page.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of database technology, and in particular to methods, apparatus, devices, media, and products for generating row identifiers in databases. Background Technology

[0002] In a database system, table data is stored in a clustered index. The system generates a row identifier (ROWID) for each row in the table, serving as a unique identifier for that row. The current maximum ROWID of the clustered index is stored on the index control page.

[0003] When inserting a new record into a clustered index, the index control page is typically locked exclusively to prevent concurrent access by other threads, and then the current maximum ROWID in the index control page is read. However, in a high-concurrency environment, a large number of threads may concurrently insert data into the same table. Each inserting thread needs to frequently lock the index control page exclusively to request a ROWID, preventing other threads from accessing the page and requesting a ROWID. This leads to increased concurrency conflicts and severely impacts the performance of concurrent index insertions. Summary of the Invention

[0004] This invention provides a method, apparatus, device, medium, and product for generating row identifiers in a database to solve the concurrency conflict problem in a high-concurrency environment when inserting new records into a clustered index.

[0005] According to one aspect of the present invention, a method for generating row identifiers in a database is provided, comprising: Obtain the index and the dictionary object corresponding to the index, wherein the index includes the index corresponding to the table to which the data is to be inserted, and the dictionary object includes the identifier of the current largest row in the index; If the index includes a primary key, then the first current maximum row identifier is read from the dictionary object of the index, and a temporary variable is determined based on the first current maximum row identifier; Determine whether the temporary variable is a multiple of a preset value; If the temporary variable is not a multiple of the preset value, then a comparison and swap operation is performed on the second current maximum row identifier in the dictionary object and the temporary variable, and the row identifier result is determined according to the temporary variable. The reading time of the second current maximum row identifier is later than that of the first current maximum row identifier. The comparison and swap operation includes updating the dictionary object according to the temporary variable based on the numerical relationship between the second current maximum row identifier and the temporary variable. The row identifier result includes the row identifier assigned to the data to be inserted. If the temporary variable is a multiple of the preset value, then enter the critical section, obtain the third current maximum row identifier in the dictionary object, update the dictionary object and index control page based on whether the third current maximum row identifier is a multiple of the preset value, determine the row identifier result based on the third current maximum row identifier, and exit the critical section. The reading time of the third current maximum row identifier is later than that of the first current maximum row identifier.

[0006] According to another aspect of the present invention, a database row identifier generation apparatus is provided, comprising: The acquisition module is used to acquire an index and a dictionary object corresponding to the index. The index includes the index corresponding to the table to which the data is to be inserted, and the dictionary object includes the identifier of the current largest row in the index. The reading module is configured to, if the index includes a primary key, read the first current maximum row identifier from the dictionary object of the index, and determine a temporary variable based on the first current maximum row identifier; The judgment module is used to determine whether the temporary variable is a multiple of a preset value; The first determining module is configured to, if the temporary variable is not a multiple of the preset value, perform a comparison and swap operation on the second current maximum row identifier in the dictionary object and the temporary variable, and determine the row identifier result based on the temporary variable. The second current maximum row identifier is read later than the first current maximum row identifier. The comparison and swap operation includes updating the dictionary object based on the numerical relationship between the second current maximum row identifier and the temporary variable. The row identifier result includes the row identifier assigned to the data to be inserted. The second determining module is used to enter the critical section if the temporary variable is a multiple of the preset value, obtain the third current maximum row identifier in the dictionary object, update the dictionary object and index control page based on whether the third current maximum row identifier is a multiple of the preset value, determine the row identifier result based on the third current maximum row identifier, and exit the critical section. The reading time of the third current maximum row identifier is later than that of the first current maximum row identifier.

[0007] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the method described in any embodiment of the present invention.

[0008] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the method described in any embodiment of the present invention.

[0009] According to another aspect of the present invention, a computer program product is provided, the computer program product comprising a computer program that, when executed by a processor, implements the method described in any embodiment of the present invention.

[0010] The technical solution of this invention involves obtaining an index and a dictionary object corresponding to the index. The index includes an index corresponding to the table to which data is to be inserted, and the dictionary object includes the current largest row identifier in the index. If the index includes a primary key, a first current largest row identifier is read from the dictionary object of the index, and a temporary variable is determined based on the first current largest row identifier. It is then determined whether the temporary variable is a multiple of a preset value. If the temporary variable is not a multiple of the preset value, a comparison and swap operation is performed between the second current largest row identifier in the dictionary object and the temporary variable, and the row identifier result is determined based on the temporary variable. The reading time of the second current largest row identifier is later than that of the first current largest row identifier. The comparison and exchange operation includes updating the dictionary object based on the numerical relationship between the second current maximum row identifier and the temporary variable. The row identifier result includes the row identifier assigned to the data to be inserted. If the temporary variable is a multiple of a preset value, the system enters a critical section, obtains the third current maximum row identifier in the dictionary object, updates the dictionary object and index control page based on whether the third current maximum row identifier is a multiple of the preset value, determines the row identifier result based on the third current maximum row identifier, and exits the critical section. The reading time of the third current maximum row identifier is later than that of the first current maximum row identifier. This embodiment of the invention uses a dictionary object to store the current maximum row identifier in the index, avoiding concurrency conflicts caused by multiple insertion threads frequently locking the index control page in high-concurrency scenarios. This improves the concurrent insertion performance of row identifiers in high-concurrency scenarios, thereby improving the overall database performance.

[0011] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description

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

[0013] Figure 1 This is a flowchart of a method for generating row identifiers in a database, provided in Embodiment 1 of the present invention; Figure 2 This is a flowchart of a method for generating row identifiers in a database, provided in Embodiment 2 of the present invention; Figure 3 This is a schematic diagram of a row identifier generation device in a database provided in Embodiment 3 of the present invention; Figure 4 A schematic diagram of an electronic device that can be used to implement embodiments of the present invention is shown. Detailed Implementation

[0014] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0015] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0016] In a database system, table data is stored in a clustered index. The system generates a logical ROWID for each row in the table, serving as a unique identifier for that row. The index control page can be used to store the current maximum ROWID of the clustered index.

[0017] When inserting a new record into a clustered index, the existing ROWID generation method is as follows: 1. Implement exclusive locking on the index control page to prevent other threads from accessing it concurrently.

[0018] 2. Read the current maximum ROWID from the control page, increment its value by 1, and use it as the newly generated ROWID.

[0019] 3. Write the newly generated ROWID back to the control page, record the redo log of the modified page, and then release the exclusive lock on the page.

[0020] This generation method guarantees the uniqueness and incrementability of ROWIDs, and is the approach adopted by most database systems. However, in high-concurrency environments, a large number of threads may concurrently insert data into the same table. Each thread needs to frequently lock the control page to request a ROWID, preventing other threads from accessing the page and requesting a ROWID. This leads to increased concurrency conflicts and severely impacts the performance of concurrent inserts into the index. Furthermore, each ROWID generation requires recording a redo log of the modified page, generating disk input / output (IO) overhead.

[0021] To address this, this invention proposes a novel ROWID generation method that optimizes the ROWID generation process under high concurrency. While ensuring correctness, it reduces concurrency conflicts caused by accessing the index control page when requesting ROWID, while also reducing the amount of redo logs generated during ROWID generation. This improves the concurrent insertion performance of indexes under high concurrency, thereby enhancing the overall performance of the database.

[0022] Example 1 Figure 1 This is a flowchart of a row identifier generation method in a database according to Embodiment 1 of the present invention. This embodiment is applicable to generating row identifiers for each row of data in a table under high concurrency scenarios. This method can be executed by a database row identifier generation device, which can be implemented in hardware and / or software and can be configured in an electronic device. For example, the electronic device can be a computer, workstation, or server. Figure 1 As shown, the method includes: S110. Obtain the index and the dictionary object corresponding to the index, wherein the index includes the index corresponding to the table to be inserted, and the dictionary object includes the current largest row identifier in the index.

[0023] In this embodiment, the index can be a unique index of the table into which data is to be inserted. The index can be a clustered index. The dictionary object can be a dictionary object in memory used to store the current largest row identifier. The data to be inserted can be a data segment from the table into which data is to be inserted.

[0024] For example, the current maximum row identifier is stored in the dictionary object as an atomic variable. This atomic variable format ensures that when multiple threads concurrently read data from the dictionary object, they can still obtain a consistent current maximum row identifier without blocking the index control page and the dictionary object itself, and without reading intermediate or partially updated values.

[0025] Specifically, in response to a request to insert data into a table, the database asynchronously initiates a thread to insert data into the table, and obtains the table's index and a dictionary object of the index through the thread.

[0026] S120. If the index includes a primary key, then read the first current maximum row identifier from the dictionary object of the index, and determine a temporary variable based on the first current maximum row identifier.

[0027] In this embodiment, the primary key can be one or more fields in the table. The primary key can be used to uniquely identify each record in the table. The first current maximum row identifier can be the current maximum row identifier obtained from a dictionary object. The temporary variable can be a parameter temporarily maintained in memory. After reading the first current maximum row identifier, the first current maximum row identifier is assigned to the temporary variable.

[0028] Specifically, if the index has a primary key, the identifier of the first current maximum row is read from the dictionary object of the index, and the value of the first current maximum row identifier is stored in a temporary variable.

[0029] S130. Determine whether the temporary variable is a multiple of the preset value.

[0030] In this embodiment, the preset value can be a threshold for batch writing row identifiers back to the index control page. By setting a preset value, the current largest row identifier is only written back to the index control page when the temporary variable is a multiple of the preset value, thereby reducing the number of modifications to the index control page and the amount of redo log generation. The preset value can be determined based on the table's update frequency and / or experience, and this invention does not impose any limitations on it. For example, the preset threshold could be 256.

[0031] Specifically, a preset value is determined in advance, and it is determined whether the temporary variable is a multiple of the preset value.

[0032] S140. If the temporary variable is not a multiple of the preset value, a comparison and swap operation is performed on the second current maximum row identifier in the dictionary object and the temporary variable, and the row identifier result is determined according to the temporary variable. The reading time of the second current maximum row identifier is later than that of the first current maximum row identifier. The comparison and swap operation includes updating the dictionary object according to the temporary variable based on the numerical relationship between the second current maximum row identifier and the temporary variable. The row identifier result includes the row identifier assigned to the data to be inserted. The execution ends.

[0033] In this embodiment, the second current maximum row identifier can be the row identifier obtained through a comparison and swap operation when the temporary variable is not a multiple of a preset value. Obtaining the second current maximum row identifier through a comparison and swap operation prevents other threads from updating the dictionary object while the determination of whether the temporary variable is a multiple of the preset value is being performed. Other threads can be other threads that insert data into the table and assign row identifiers to the data. The comparison and swap operation can be an operation used to obtain and update the dictionary object based on the comparison result between the second current maximum row identifier and the temporary variable. The comparison and swap operation can be performed without being interrupted by other threads. The comparison and swap operation can update the dictionary object without locking it. The row identifier result can be the row identifier assigned to the newly inserted data in the table. The numerical relationship can be a relationship used to indicate whether the second current maximum row identifier and the temporary variable are equal.

[0034] Specifically, if the temporary variable is not a multiple of the preset value, the index control page is not updated. Instead, a comparison and swap operation is performed, and the row identifier result is determined based on the temporary variable. Specifically, the comparison and swap operation includes: obtaining and updating the dictionary object by incrementing the temporary variable by one, without locking, based on the numerical relationship between the second current maximum row identifier and the temporary variable.

[0035] S150. If the temporary variable is a multiple of the preset value, then enter the critical section, obtain the third current maximum row identifier in the dictionary object, update the dictionary object and index control page based on whether the third current maximum row identifier is a multiple of the preset value, determine the row identifier result based on the third current maximum row identifier, and exit the critical section. The reading time of the third current maximum row identifier is later than that of the first current maximum row identifier.

[0036] In this embodiment, the third current maximum row identifier can be the current maximum row identifier reread from the dictionary object when the temporary variable is a multiple of a preset value. To prevent other threads from updating the dictionary object while determining whether the temporary variable is a multiple of the preset value, the third current maximum row identifier is reread after the determination.

[0037] Specifically, if the temporary variable is a multiple of the preset value, the dictionary object needs to be updated based on the temporary variable. At this point, the critical section of the dictionary object is entered, and the current maximum row identifier on the dictionary object is reread as the third current maximum row identifier. It is then checked again whether the third current maximum row identifier is a multiple of the preset value. If it is, the index control page is locked, the index control page is updated based on the third current maximum row identifier, and the dictionary object is updated based on the third current maximum row identifier. The locking is then lifted, the row identifier result is determined based on the third current maximum row identifier, and the critical section is exited. If it is not, there is no need to write back to the index control page. The dictionary object is updated based on the third current maximum row identifier, the row identifier result is determined based on the third current maximum row identifier, and the critical section is exited.

[0038] The technical solution of this invention involves obtaining an index and a dictionary object corresponding to the index. The index includes an index corresponding to the table to which data is to be inserted, and the dictionary object includes the current largest row identifier in the index. If the index includes a primary key, a first current largest row identifier is read from the dictionary object of the index, and a temporary variable is determined based on the first current largest row identifier. It is then determined whether the temporary variable is a multiple of a preset value. If the temporary variable is not a multiple of the preset value, a comparison and swap operation is performed between the second current largest row identifier in the dictionary object and the temporary variable, and the row identifier result is determined based on the temporary variable. The reading time of the second current largest row identifier is later than that of the first current largest row identifier. The comparison and exchange operation includes updating the dictionary object based on the numerical relationship between the second current maximum row identifier and the temporary variable. The row identifier result includes the row identifier assigned to the data to be inserted. If the temporary variable is a multiple of a preset value, the system enters a critical section, obtains the third current maximum row identifier in the dictionary object, updates the dictionary object and index control page based on whether the third current maximum row identifier is a multiple of the preset value, determines the row identifier result based on the third current maximum row identifier, and exits the critical section. The reading time of the third current maximum row identifier is later than that of the first current maximum row identifier. This embodiment of the invention uses a dictionary object to store the current maximum row identifier in the index, avoiding concurrency conflicts caused by multiple insertion threads frequently locking the index control page in high-concurrency scenarios. This improves the concurrent insertion performance of row identifiers in high-concurrency scenarios, thereby improving the overall database performance.

[0039] In one embodiment, if the index includes a primary key, the process before retrieving the dictionary object further includes: A1. Obtain the current largest row identifier registered on the index control page, and use it as the control page row identifier.

[0040] In this embodiment, the control page row identifier can be the largest row identifier currently in the index control page.

[0041] Specifically, before obtaining the dictionary object, the control page row identifier registered on the index control page is obtained to initialize the dictionary object.

[0042] A2. Increment the control page row identifier to a value that is closest to a multiple of the preset value, and store the value in a dictionary object as an atomic variable.

[0043] Specifically, the row identifier of the index control page is incremented to a value that is closest to a preset value to reduce the modification frequency of the index control page. The value is stored in a dictionary object as an atomic variable for subsequent unblocked retrieval of the current maximum row identifier. The value is written back to the index control page, and a redo log for the modified page is generated after the index control page is updated.

[0044] In one embodiment, performing a comparison and swap operation on the second current maximum row identifier in the dictionary object and the temporary variable, and determining the row identifier result based on the temporary variable, includes: S1401. If the second current maximum row identifier is equal to the temporary variable, then update the dictionary object by incrementing the temporary variable by one.

[0045] Specifically, if the second current maximum row identifier is equal to the temporary variable, then the dictionary object is updated to the temporary variable plus one.

[0046] S1402. If the second current maximum row identifier is not equal to the temporary variable, the comparison and swap operation fails, and the temporary variable is reacquired until the comparison and swap operation succeeds.

[0047] Specifically, if the second current maximum row identifier is not equal to the temporary variable, it means that another thread has modified the current maximum row identifier on the dictionary object. In this case, the comparison and swap operation fails, and the current maximum row identifier is retrieved again from the indexed dictionary object. The temporary variable is then checked to see if it is a multiple of the preset value, until the comparison and swap operation succeeds.

[0048] S1403. The temporary variable is determined as the row identifier result.

[0049] Specifically, the temporary variable is set as the row identifier result, and the row identifier result is returned to the thread.

[0050] In one embodiment, updating the dictionary object and index control page based on the third current maximum row identifier, and determining the row identifier result based on the third current maximum row identifier, includes: S1501. If the third current maximum row identifier is a multiple of the preset value, then the index control page is updated using the third current maximum row identifier, the third current maximum row identifier is determined as the row identifier result, and the dictionary object is updated by incrementing the third current maximum row identifier by one.

[0051] Specifically, if the third current maximum row identifier is a multiple of the preset value, the index control page is locked, the index control page is updated using the third current maximum row identifier, the corresponding redo log is generated after the index control page is updated, the lock is released, the third current maximum row identifier is determined as the row identifier result, and the dictionary object is updated to the temporary variable incremented by one.

[0052] S1502. If the third current maximum row identifier is not a multiple of the preset value, then the third current maximum row identifier is determined as the row identifier result, and the dictionary object is updated by incrementing the third current maximum row identifier by one.

[0053] Specifically, if the third current maximum row identifier is not a multiple of the preset value, then the third current maximum row identifier is determined as the row identifier result, and the dictionary object is updated by incrementing the third current maximum row identifier by one.

[0054] In one embodiment, the first current maximum row identifier and the second current maximum row identifier include row identifiers obtained without blocking the dictionary object and the index control page; the third current maximum row identifier includes row identifiers obtained after entering the critical section of the dictionary object and blocking the dictionary object.

[0055] Specifically, the current maximum row identifier is stored as an atomic variable in a dictionary object in memory. When reading the first and second current maximum row identifiers, it's not necessary to lock the dictionary object. This also ensures that multiple threads generating row identifiers simultaneously will not experience concurrent waiting. Concurrency synchronization is achieved by using comparison and swap operations and re-acquiring temporary variables to determine numerical relationships, guaranteeing the correctness of the generated row identifiers—that is, the generated row identifiers are continuously incremented, and no two threads will request the same row identifier. A critical section is needed to obtain the third current maximum row identifier, protecting the current maximum row identifier on the dictionary object. The same write-back operation is also required when destroying the index dictionary object from memory. The redo log of the modified pages generated after updating the index control page ensures data consistency after fault recovery.

[0056] Example 2 Figure 2This is a flowchart illustrating a row identifier generation method in a database according to Embodiment 2 of the present invention. This embodiment is an optimization based on any of the above embodiments, and mainly includes a detailed description of the process for determining the row identifier result when the index does not include the primary key. It should be noted that technical details not described in detail in this embodiment can be found in any of the above embodiments. Figure 2 As shown, the method includes: S210. Obtain the index and the dictionary object corresponding to the index, wherein the index includes the index corresponding to the table to which the data is to be inserted, and the dictionary object includes the identifier of the current largest row in the index.

[0057] S220. If the index does not include the primary key, then obtain the largest record in the index, increment the row identifier of the largest record by one and use it as the row identifier result. The largest record includes the last record in the rightmost leaf page of the index, and then end the execution.

[0058] In this embodiment, the largest record can be the record with the largest ROWID in the index. The last record in the rightmost leaf page has the largest row ID at present.

[0059] Specifically, if the index does not include the primary key, since row identifiers are globally incrementing, the row identifier of the data to be inserted will always be greater than the current largest row identifier in the index. Therefore, the row identifier of the data to be inserted will definitely be inserted after the last record of the rightmost leaf page of the index. After accessing the rightmost leaf page, the last record in the rightmost leaf page has the current largest row identifier in the index. Incrementing the value of the row identifier of the last record by 1 will give the result of the row identifier of the data to be inserted, without the need for additional access to the index control page to allocate row identifiers.

[0060] Optionally, it also includes using the row identifier in the index as the implicit primary key of the index.

[0061] In this embodiment, an implicit primary key can be the state of the primary key when no explicit primary key is defined. An explicit primary key can be a field in the table that is explicitly defined as a primary key and is supported by an index.

[0062] Specifically, if the index does not include a primary key, then the index is in an implicit primary key state, and the row identifier is used as the implicit primary key of the index.

[0063] S230. If the index includes a primary key, then read the first current maximum row identifier from the dictionary object of the index, and determine a temporary variable based on the first current maximum row identifier.

[0064] S240. Determine whether the temporary variable is a multiple of the preset value.

[0065] S250. If the temporary variable is not a multiple of the preset value, a comparison and swap operation is performed on the second current maximum row identifier in the dictionary object and the temporary variable, and the row identifier result is determined according to the temporary variable. The reading time of the second current maximum row identifier is later than that of the first current maximum row identifier. The comparison and swap operation includes updating the dictionary object according to the temporary variable based on the numerical relationship between the second current maximum row identifier and the temporary variable. The row identifier result includes the row identifier assigned to the data to be inserted. The execution ends.

[0066] S260. If the temporary variable is a multiple of the preset value, then enter the critical section, obtain the third current maximum row identifier in the dictionary object, update the dictionary object and index control page based on whether the third current maximum row identifier is a multiple of the preset value, determine the row identifier result based on the third current maximum row identifier, and exit the critical section. The reading time of the third current maximum row identifier is later than that of the first current maximum row identifier.

[0067] The technical solution of this invention involves obtaining an index and a dictionary object corresponding to the index. The index includes the index corresponding to the table to which data is to be inserted, and the dictionary object includes the current largest row identifier in the index. If the index does not include a primary key, the largest record in the index is obtained, and the row identifier in the largest record is incremented by one to obtain the row identifier result. The largest record includes the last record in the rightmost leaf page of the index. If the index includes a primary key, a first current largest row identifier is read from the dictionary object of the index, and a temporary variable is determined based on the first current largest row identifier. It is then determined whether the temporary variable is a multiple of a preset value. If the temporary variable is not a multiple of the preset value, a comparison and swap operation is performed on the second current largest row identifier in the dictionary object and the temporary variable, and the result is determined based on the... The temporary variable is used to determine the row identifier result. The second current maximum row identifier is read later than the first current maximum row identifier. The comparison and exchange operation includes updating the dictionary object based on the numerical relationship between the second current maximum row identifier and the temporary variable. The row identifier result includes the row identifier allocated to the data to be inserted. If the temporary variable is a multiple of a preset value, the process enters a critical section, obtains the third current maximum row identifier in the dictionary object, updates the dictionary object and the index control page based on whether the third current maximum row identifier is a multiple of the preset value, determines the row identifier result based on the third current maximum row identifier, and exits the critical section. The third current maximum row identifier is read later than the first current maximum row identifier. This embodiment of the invention, by adding one to the row identifier of the last record in the rightmost leaf page of the index to determine the row identifier result when the index does not include a primary key, avoids concurrency conflicts caused by multiple insertion threads frequently locking the index control page in high-concurrency scenarios, without needing to additionally access the index control page to allocate row identifiers.

[0068] The present invention will be described by way of example below: This invention provides a ROWID generation method, comprising: if the index has no primary key, then using ROWID as the implicit primary key of the index; when generating ROWID, obtaining the record with the largest ROWID in the index, i.e., the last record in the rightmost leaf page, and incrementing its ROWID value by 1 as the newly generated ROWID (i.e., row identifier result). If the index has a primary key, then storing the current largest ROWID of the index as an atomic variable in an index dictionary object (i.e., a dictionary object) in memory, periodically writing it back to the control page (i.e., the index control page); when generating ROWID, lock-free operation is achieved based on comparison and swap operations, significantly reducing concurrency conflicts caused by generating ROWID; the control page is locked and a redo log of the modified page is generated only when writing back the current largest ROWID. The above ROWID generation method improves the performance of generating ROWID in high-concurrency scenarios and improves the performance of concurrent index insertion.

[0069] In one embodiment, a method for generating row identifiers in a database includes: When a clustered index dictionary object with a primary key is initialized, the index control page is accessed to obtain the current maximum ROWID (i.e., the control page row identifier) ​​registered on the index control page. Its value is incremented to the nearest multiple of 256 and used as the new current maximum ROWID. This new ROWID is stored in the dictionary object's memory structure as an atomic variable. The new current maximum ROWID is then written back to the control page, and the redo log of the modified page is generated.

[0070] When the insertion thread (i.e., the thread that inserts the data to be inserted) requests a ROWID, the following steps are performed: Step 1: If the index has no primary key, the new record (i.e., the data to be inserted) will be inserted after the largest record in the rightmost leaf page of the index. After accessing the rightmost leaf page, the last record in the page is retrieved, its ROWID value is incremented by 1 as the newly generated ROWID and returned.

[0071] Step 2: If the index has a primary key, read the current maximum ROWID (i.e., the identifier of the first current maximum row) from the dictionary object of the index and store it in a temporary variable.

[0072] Step 3: Determine if the temporary variable value obtained in Step 2 is a multiple of 256 (i.e., the preset value). If the temporary variable value is a multiple of 256, skip Step 3 and proceed directly to Step 4. If it is not a multiple of 256, there is no need to write back to the control page. Perform the following comparison and swap operation on the current maximum ROWID on the dictionary object: Compare the current maximum ROWID (i.e., the second current maximum row identifier) ​​on the dictionary object with the temporary variable. If they are equal, increment the current maximum ROWID by 1 and return the original value (temporary variable value) as the generated ROWID (i.e., the row identifier result). If they are not equal, it means that another thread has modified the value, so the operation fails, and Step 2 is re-executed to retry.

[0073] Step 4: If the temporary variable value read in Step 2 is a multiple of 256, it needs to be written back to the control page. At this point, the critical section of the dictionary object is entered, and the current maximum ROWID (i.e., the third current maximum row identifier) ​​on the dictionary object is read again. It is then checked again whether it is a multiple of 256 (other threads may have modified this value before entering the critical section). If it is, the index control page is exclusively locked, the current maximum ROWID is written back to the index control page, a redo log of the modified page is generated, the exclusive lock on the index control page is released, and its value is used as the generated ROWID. Then, the current maximum ROWID on the dictionary object is incremented by 1, and the critical section is exited. If it is not, there is no need to write back to the control page. Its value is used as the generated ROWID (i.e., the row identifier result), and then the current maximum ROWID on the dictionary object is incremented by 1, and the critical section is exited.

[0074] In step 1, since the index without a primary key uses ROWID as the implicit primary key, and ROWID is globally incremented, the ROWID of the new record will always be greater than the current maximum ROWID in the index. Therefore, the new record will definitely be inserted after the maximum record in the rightmost leaf page of the index. After accessing the rightmost leaf page, the last record in the page has the current maximum ROWID of the index. Incrementing its value by 1 will give it the ROWID of the new record, without needing to access the index control page to allocate a ROWID.

[0075] In step 2, the current maximum ROWID on the index dictionary object is an atomic variable. When reading the temporary variable, atomic reading is used to ensure that a complete and consistent value can be obtained when multiple threads read concurrently.

[0076] In step 3, the comparison and swap operation uses the Compare-And-Swap (CAS) instruction. The CAS instruction can take the form CAS(V, A, B), meaning: compare the current value of memory location V with the original value A. If they are equal, update the value of memory location V to the new value B, and the operation succeeds; if they are not equal, the operation fails and usually needs to be retried. The entire comparison and swap operation is an indivisible single comparison-and-swap operation. When multiple threads attempt to update the same atomic variable, locking is not required; instead, synchronization is achieved through CAS operations and a spin mechanism (i.e., if the second current maximum row ID is not equal to the temporary variable, the temporary variable is reacquired until the second current maximum row ID is equal to the temporary variable). The specific CAS operation executed in step 3 is: CAS(current maximum ROWID, temporary variable, temporary variable + 1). The current maximum ROWID (i.e., the second current maximum row identifier) ​​is an atomic variable on the index dictionary object. The temporary variable is read from the dictionary object in step 2. According to the definition of the CAS operation, the meaning of this operation is: compare the current maximum ROWID on the dictionary object with the temporary variable. If they are equal, update the current maximum ROWID on the dictionary object to the temporary variable + 1. If they are not equal, the operation fails. The atomicity of the entire operation is guaranteed by the Central Processing Unit (CPU) hardware.

[0077] As can be seen, steps 2 and 3 are completely unblocked. When multiple threads generate ROWIDs simultaneously, there will be no concurrent waiting. Concurrent synchronization is achieved by using CAS and spin retries to ensure the correctness of concurrently generated ROWIDs. That is, the generated ROWIDs are continuously incremented, and no two threads will request the same ROWID.

[0078] Step 4 ensures that the current maximum ROWID is written back to the control page every 256 ROWIDs requested, preventing a large discrepancy between the value on the dictionary object and the value on the control page. The critical section used during the write-back to the control page protects the current maximum ROWID on the dictionary object. The same write-back operation is also required when destroying the index dictionary object from memory. Generating redo logs for modified pages ensures data consistency after fault recovery.

[0079] When a database fails or crashes, for indexes with primary keys, ROWIDs may have already been generated by insert operations, but the values ​​on the dictionary object are not multiples of 256 and were not written back to the control page in time. In this case, the current maximum ROWID on the index dictionary object is greater than the current maximum ROWID on the control page. After restarting the database, the system will recover the data on the control page based on the redo log. Since the memory structure of the dictionary object has been lost, the current maximum ROWID on the control page cannot be used directly when constructing the index dictionary object. This is because a larger ROWID may have been generated and inserted into the index before the crash, and directly using the current maximum ROWID on the control page could lead to ROWID duplication. Therefore, the current maximum ROWID on the control page needs to be incremented to the nearest multiple of 256. Since step 4 ensures that the current maximum ROWID is written back to the control page every time 256 ROWIDs are requested, the incremented ROWIDs will definitely not be used, avoiding ROWID duplication. Since ROWIDs are usually six-byte or eight-byte long integers, a maximum of 255 ROWIDs are wasted each time, which can be ignored. This ensures that the uniqueness and increment of ROWID are guaranteed even in the event of a failure.

[0080] In summary, this invention proposes a novel ROWID generation method that significantly reduces conflicts caused by concurrent ROWID generation and decreases the amount of redo logs generated. In high-concurrency environments, the ROWID generation method of this invention significantly outperforms existing methods, improving concurrent insertion performance, enhancing concurrent read / write performance of indexes, and achieving high concurrency and high availability of clustered indexes, thereby improving the overall performance of the database system.

[0081] Example 3 Figure 3 This is a schematic diagram of a database row identifier generation device provided in Embodiment 3 of the present invention. Figure 3 As shown, the device includes: The acquisition module 310 is used to acquire an index and a dictionary object corresponding to the index, wherein the index includes the index corresponding to the table to be inserted, and the dictionary object includes the identifier of the current largest row in the index; The reading module 320 is configured to, if the index includes a primary key, read the first current maximum row identifier from the dictionary object of the index, and determine a temporary variable based on the first current maximum row identifier; The judgment module 330 is used to determine whether the temporary variable is a multiple of a preset value; The first determining module 340 is configured to, if the temporary variable is not a multiple of the preset value, perform a comparison and exchange operation on the second current maximum row identifier in the dictionary object and the temporary variable, and determine the row identifier result based on the temporary variable. The reading time of the second current maximum row identifier is later than that of the first current maximum row identifier. The comparison and exchange operation includes updating the dictionary object based on the numerical relationship between the second current maximum row identifier and the temporary variable. The row identifier result includes the row identifier assigned to the data to be inserted. The second determining module 350 is used to enter the critical section if the temporary variable is a multiple of the preset value, obtain the third current maximum row identifier in the dictionary object, update the dictionary object and index control page based on whether the third current maximum row identifier is a multiple of the preset value, determine the row identifier result based on the third current maximum row identifier, and exit the critical section. The reading time of the third current maximum row identifier is later than that of the first current maximum row identifier.

[0082] The technical solution of this invention involves an acquisition module obtaining an index and a dictionary object corresponding to the index. The index includes an index corresponding to the table to which data is to be inserted, and the dictionary object includes the current largest row identifier in the index. If the index includes a primary key, a reading module reads the first current largest row identifier from the dictionary object of the index and determines a temporary variable based on the first current largest row identifier. A determination module determines whether the temporary variable is a multiple of a preset value. If the temporary variable is not a multiple of the preset value, a first determination module compares and swaps the second current largest row identifier in the dictionary object with the temporary variable and determines the row identifier result based on the temporary variable. The reading time of the second current largest row identifier is later than the time when the table to be inserted is inserted. The first current maximum row identifier is described. The comparison and exchange operation includes updating the dictionary object based on the numerical relationship between the second current maximum row identifier and the temporary variable. The row identifier result includes the row identifier assigned to the data to be inserted. If the temporary variable is a multiple of a preset value, the second determining module enters the critical section, obtains the third current maximum row identifier in the dictionary object, updates the dictionary object and index control page based on whether the third current maximum row identifier is a multiple of the preset value, determines the row identifier result based on the third current maximum row identifier, and exits the critical section. The reading time of the third current maximum row identifier is later than that of the first current maximum row identifier. This embodiment of the invention uses a dictionary object to store the current maximum row identifier in the index, avoiding concurrency conflicts caused by multiple insertion threads frequently locking the index control page in high-concurrency scenarios. This improves the concurrent insertion performance of row identifiers in high-concurrency scenarios, thereby improving the overall database performance.

[0083] In one embodiment, the device further includes: The maximum record acquisition module is used to acquire the maximum record in the index if the index does not include the primary key, and to obtain the row identifier of the maximum record by adding one to it as the row identifier result. The maximum record includes the last record in the rightmost leaf page of the index.

[0084] In one embodiment, the device further includes: An implicit primary key determination module is used to use the row identifier in the index as the implicit primary key of the index.

[0085] In one embodiment, if the index includes a primary key, the process further includes, before retrieving the dictionary object: Obtain the current largest row identifier registered on the index control page, and use it as the control page row identifier; The control page row identifier is incremented to a value that is closest to a multiple of the preset value, and the value is stored in a dictionary object as an atomic variable.

[0086] In one embodiment, the first determining module 340 is specifically used for: If the second current maximum row identifier is equal to the temporary variable, then the dictionary object is updated by incrementing the temporary variable by one; If the second current maximum row identifier is not equal to the temporary variable, the comparison and swap operation fails, and the temporary variable is reacquired until the comparison and swap operation succeeds. The temporary variable is determined as the row identifier result.

[0087] In one embodiment, the second determining module 350 is specifically used for: If the third current maximum row identifier is a multiple of the preset value, then the index control page is updated using the third current maximum row identifier, the third current maximum row identifier is determined as the row identifier result, and the dictionary object is updated by incrementing the third current maximum row identifier by one. If the third current maximum row identifier is not a multiple of the preset value, then the third current maximum row identifier is determined as the row identifier result, and the dictionary object is updated by incrementing the third current maximum row identifier by one.

[0088] In one embodiment, the first current maximum row identifier and the second current maximum row identifier include row identifiers obtained without blocking the dictionary object and the index control page; the third current maximum row identifier includes row identifiers obtained after entering the critical section of the dictionary object and blocking the dictionary object.

[0089] The database row identifier generation device provided in this embodiment of the invention can execute the database row identifier generation method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0090] Example 4 Figure 4 A schematic diagram of an electronic device that can be used to implement embodiments 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 processors, cellular phones, smartphones, 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 illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.

[0091] like Figure 4 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 can also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

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

[0093] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as the methods proposed in this invention.

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

[0095] Various embodiments 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 parts (ASSPs), systems-on-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0096] Computer programs used to implement 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, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0097] In the context of this invention, a computer-readable storage medium stores computer instructions that are used to cause a processor to execute and implement the method provided by this invention.

[0098] The present invention also provides a computer program product comprising a computer program that, when executed by a processor, implements the method provided according to embodiments of the present invention.

[0099] Computer-readable storage media can be tangible media that may contain or store computer programs for use by or in conjunction with an instruction execution system, apparatus, or device. Computer-readable storage media can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, computer-readable storage media can be machine-readable signal media. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

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

[0101] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or middleware components (e.g., application servers), or frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.

[0102] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system. It addresses the shortcomings of traditional physical hosts and Virtual Private Server (VPS) services, such as high management difficulty and weak business scalability.

[0103] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.

[0104] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A method for generating row identifiers in a database, characterized in that, include: Obtain the index and the dictionary object corresponding to the index, wherein the index includes the index corresponding to the table to which the data is to be inserted, and the dictionary object includes the identifier of the current largest row in the index; If the index includes a primary key, then the first current maximum row identifier is read from the dictionary object of the index, and a temporary variable is determined based on the first current maximum row identifier; Determine whether the temporary variable is a multiple of a preset value; If the temporary variable is not a multiple of the preset value, then a comparison and swap operation is performed on the second current maximum row identifier in the dictionary object and the temporary variable, and the row identifier result is determined according to the temporary variable. The reading time of the second current maximum row identifier is later than that of the first current maximum row identifier. The comparison and swap operation includes updating the dictionary object according to the temporary variable based on the numerical relationship between the second current maximum row identifier and the temporary variable. The row identifier result includes the row identifier assigned to the data to be inserted. If the temporary variable is a multiple of the preset value, then enter the critical section, obtain the third current maximum row identifier in the dictionary object, update the dictionary object and index control page based on whether the third current maximum row identifier is a multiple of the preset value, determine the row identifier result based on the third current maximum row identifier, and exit the critical section. The reading time of the third current maximum row identifier is later than that of the first current maximum row identifier.

2. The method according to claim 1, characterized in that, Also includes: If the index does not include a primary key, then the maximum record in the index is obtained, and the row identifier of the maximum record is incremented by one to obtain the row identifier result. The maximum record includes the last record in the rightmost leaf page of the index.

3. The method according to claim 2, characterized in that, Also includes: The row identifier in the index is used as the implicit primary key of the index.

4. The method according to claim 1, characterized in that, If the index includes a primary key, the process before retrieving the dictionary object also includes: Obtain the current largest row identifier registered on the index control page, and use it as the control page row identifier; The control page row identifier is incremented to a value that is closest to a multiple of the preset value, and the value is stored in a dictionary object as an atomic variable.

5. The method according to claim 1, characterized in that, The step of comparing and swapping the second current maximum row identifier in the dictionary object and the temporary variable, and determining the row identifier result based on the temporary variable, includes: If the second current maximum row identifier is equal to the temporary variable, then the dictionary object is updated by incrementing the temporary variable by one; If the second current maximum row identifier is not equal to the temporary variable, the comparison and swap operation fails, and the temporary variable is reacquired until the comparison and swap operation succeeds. The temporary variable is determined as the row identifier result.

6. The method according to claim 1, characterized in that, The step of updating the dictionary object and index control page based on whether the third current maximum row identifier is a multiple of the preset value, and determining the row identifier result based on the third current maximum row identifier, includes: If the third current maximum row identifier is a multiple of the preset value, then the index control page is updated using the third current maximum row identifier, the third current maximum row identifier is determined as the row identifier result, and the dictionary object is updated by incrementing the third current maximum row identifier by one. If the third current maximum row identifier is not a multiple of the preset value, then the third current maximum row identifier is determined as the row identifier result, and the dictionary object is updated by incrementing the third current maximum row identifier by one.

7. The method according to any one of claims 1-6, characterized in that, The first current maximum row identifier and the second current maximum row identifier include row identifiers obtained without blocking the dictionary object and the index control page; the third current maximum row identifier includes row identifiers obtained after entering the critical section of the dictionary object and blocking the dictionary object.

8. A row identifier generation device in a database, characterized in that, include: The acquisition module is used to acquire an index and a dictionary object corresponding to the index. The index includes the index corresponding to the table to which the data is to be inserted, and the dictionary object includes the identifier of the current largest row in the index. The reading module is configured to, if the index includes a primary key, read the first current maximum row identifier from the dictionary object of the index, and determine a temporary variable based on the first current maximum row identifier; The judgment module is used to determine whether the temporary variable is a multiple of a preset value; The first determining module is configured to, if the temporary variable is not a multiple of the preset value, perform a comparison and swap operation on the second current maximum row identifier in the dictionary object and the temporary variable, and determine the row identifier result based on the temporary variable. The second current maximum row identifier is read later than the first current maximum row identifier. The comparison and swap operation includes updating the dictionary object based on the numerical relationship between the second current maximum row identifier and the temporary variable. The row identifier result includes the row identifier assigned to the data to be inserted. The second determining module is used to enter the critical section if the temporary variable is a multiple of the preset value, obtain the third current maximum row identifier in the dictionary object, update the dictionary object and index control page based on whether the third current maximum row identifier is a multiple of the preset value, determine the row identifier result based on the third current maximum row identifier, and exit the critical section. The reading time of the third current maximum row identifier is later than that of the first current maximum row identifier.

9. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the method of any one of claims 1-7.

11. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the method according to any one of claims 1-7.