Handling lock contention on SQL index leaf pages

The index distribution queue buffer and leaf router map system addresses lock contention on leaf pages by routing and mapping index keys, improving database performance and reducing conflicts during index key insert operations.

JP2024536123AActive Publication Date: 2024-10-04INTERNATIONAL BUSINESS MACHINE CORPORATION
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
JP2024519109
Authority / Receiving Office
JP · JP
Patent Type
Applications
Current Assignee / Owner
Priority Date
2021-10-01
Filing Date
2022-09-28
Publication Date
2024-10-04
Estimated Expiration
2042-09-28

AI Technical Summary

Technical Problem

Existing relational database management systems face inefficiencies in handling lock contention for leaf pages of indexes, particularly during index key insert operations, leading to performance impairments and increased database input/output operations.

Method used

Implementing an index distribution queue buffer and an index leaf router map to route index keys experiencing lock contention to a queue, mapping them to appropriate leaf pages once contention resolves, thereby reducing lock contention through efficient key management.

Benefits of technology

Effectively manages lock contention on leaf pages of indexes, enhancing performance by minimizing conflicts and reducing unnecessary database operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 2024536123000001_ABST
    Figure 2024536123000001_ABST
Patent Text Reader

Abstract

Handling lock contention on leaf pages of an SQL index A computer-implemented method, system, and computer program product for handling lock contention on an index (e.g., an SQL index). Leaf pages of an index are monitored for lock contention during an insert operation of an index key by a transaction. Upon detecting a lock contention on a leaf page, the next index key to be entered on such leaf page is routed to a queue of buffers. The index key stored in the queue of buffers is then mapped to the particular leaf page experiencing the lock contention on which the transaction originally attempted to store such index key, and such mapping is stored in a data structure. When such leaf page is no longer experiencing such lock contention, the appropriate index key is then removed from the buffer and stored in the appropriate leaf page based on the mapping identified in the data structure.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] The present disclosure relates generally to relational database management systems, and more specifically to handling lock contention for leaf pages of indexes (e.g., structured query language (SQL) indexes). [Background technology]

[0002] A relational database is a digital database that is based on the relational model of data. The system used to maintain a relational database is a relational database management system (RDBMS). Many relational database systems have the option to use Structured Query Language (SQL) to query and maintain the database. Summary of the Invention

[0003] In one embodiment of the present disclosure, a computer-implemented method for handling lock contention on an index comprises monitoring for lock contention on a leaf page of an index during an insert operation of an index key. In response to detecting a lock contention on the leaf page of the index, the method further comprises routing a first index key to a buffer queue, where the first index key corresponds to an index key of a transaction to be inserted into the leaf page of the index. The method additionally comprises storing a mapping of the first index key stored in the buffer queue to a leaf page experiencing a lock contention in a data structure, where the data structure stores the mapping of the index key stored in the buffer queue to the leaf page of the index.

[0004] Other aspects of the above described computer-implemented method embodiments are in the form of a system and in the form of a computer program product.

[0005] According to one aspect, a computer program product for handling lock contention on an index is provided, the computer program product comprising one or more computer readable storage media having program code embodied thereon, the program code having programming instructions for: monitoring for lock contention on a leaf page of an index during an index key insert operation; in response to detecting the lock contention on the leaf page of the index, routing a first index key to a queue of a buffer, where the first index key corresponds to an index key of a transaction to be inserted into the leaf page of the index; and storing a mapping of the first index key stored in the queue of the buffer to the leaf page experiencing the lock contention in a data structure, where the data structure stores the mapping of the index key stored in the queue of the buffer to the leaf page of the index.

[0006] According to another aspect, a system is provided comprising: a memory for storing a computer program for handling lock contention on an index; and a processor coupled to the memory, where the processor is configured to execute program instructions of a computer program having the following steps: monitoring for lock contention on a leaf page of the index during an index key insert operation; in response to detecting the lock contention on the leaf page of the index, routing a first index key to a queue of a buffer, where the first index key corresponds to an index key of a transaction to be inserted into the leaf page of the index; and storing a mapping of the first index key stored in the queue of the buffer to the leaf page experiencing the lock contention in a data structure, where the data structure stores the mapping of the index key stored in the queue of the buffer to the leaf page of the index.

[0007] The foregoing has outlined rather generally the features and technical advantages of one or more embodiments of the present disclosure in order that the detailed description of the disclosure that follows may be better understood. Additional features and advantages of the present disclosure will be described hereinafter and may form the subject of the claims of the present disclosure. [Brief description of the drawings]

[0008] One or more preferred embodiments of the invention will now be described, by way of example only, with reference to the following drawings, in which:

[0009] [Figure 1] 1 illustrates a communication system embodying the principles of the present disclosure, in accordance with an embodiment of the disclosure;

[0010] [Diagram 2] FIG. 2 illustrates software components of a relational database management system for efficiently handling lock contention for leaf pages of an index in accordance with an embodiment of the present disclosure.

[0011] [Diagram 3] 1 illustrates an embodiment of the present disclosure of a hardware configuration for a relational database management system that is representative of a hardware environment for practicing the present disclosure.

[0012] [Figure 4] 1 is a flowchart of a method for handling lock contention on a leaf page of an index according to an embodiment of the present disclosure.

[0013] [Diagram 5] 1 illustrates monitoring for lock contention on a leaf page of an index during an insert operation of an index key into the leaf page, according to an embodiment of the present disclosure.

[0014] [Figure 6] 1 illustrates the routing of an index key from a transaction involving an attempt to store an index key on a leaf page experiencing a lock contention to a queue of an index distribution queue buffer in accordance with an embodiment of the present disclosure.

[0015] [Figure 7] 1 is a flowchart of a method for handling storage of additional index keys according to an embodiment of the present disclosure.

[0016] [Figure 8] 1 is a flowchart of a method for asynchronously inserting an index key into an appropriate leaf page that previously experienced a lock contention, according to an embodiment of the present disclosure.

[0017] [Figure 9]1 is a flowchart of a method for synchronously inserting an index key into a leaf page in response to detecting an index split on the leaf page, a system checkpoint involving the leaf page, or receiving a SELECT, UPDATE, or DELETE statement involving the leaf page, in accordance with an embodiment of the present disclosure.

[0018] [Figure 10] 1 is a flowchart of a method for pre-allocating leaf pages during an index split when a potential future lock conflict is detected, according to an embodiment of the present disclosure. [Figure 11] 1 illustrates pre-allocating leaf pages during index splitting, according to an embodiment of the present disclosure. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0019] As mentioned in the Background section, a relational database is a digital database that is based on a relational model of data. The systems used to maintain relational databases are Relational Database Management Systems (RDBMS). Many relational database systems have the option to use Structured Query Language (SQL) to query and maintain the database.

[0020] An SQL query, such as an SQL INSERT INTO statement, may be received and processed by a relational database management system (e.g., SQL Server). Such a query (e.g., an SQL INSERT INTO statement) may be used to add a new row of data to a table in a database. When such a scenario occurs, any associated indexes defined on this table need to be updated.

[0021] An index is an on-disk structure associated with a table or view that speeds up retrieval of rows from the table or view. An index typically contains a key constructed from one or more columns in the table or view. These keys are stored in a structure (a B-tree) that allows a relational database management system to quickly and efficiently find the row or rows associated with the key value. As a result, when new rows of data are added to a table in a database, the index must be updated to include the key values ​​associated with those rows of data. Storing such key values ​​in an index is referred to herein as a "transaction."

[0022] A B-tree index creates a multi-level tree structure that divides the database into fixed-size blocks or pages. This tree at each level can be used to link the pages together via address locations, allowing one page (known as a node or interior page) to reference another page at the lowest level, a leaf page. One page is usually the beginning or "root" of the tree, where a search for a particular key begins and follows a path that ends at a leaf. That is, the leaf pages of an index are the lowest level of the index, where all the keys for that index appear in sorted order. Most pages in such a structure are leaf pages that ultimately reference particular table rows.

[0023] Occasionally, multiple different transactions attempt to insert key values ​​into the leaf pages of an index (e.g., an SQL index) simultaneously, resulting in "lock contention" that adversely affects performance. A "lock contention" occurs whenever one process (transaction) attempts to acquire a "lock" that is held by another process (transaction).

[0024] In an attempt to address lock contention, such transactions may be handled in a randomized manner, however, processing of queries, such as SQL queries, associated with such transactions may suffer performance.

[0025] Furthermore, in another attempt to address lock contention, the minimum page size of an index's leaf pages can be increased, however this only results in a slight reduction in lock contention. Furthermore, increasing the minimum page size of an index's leaf pages results in more database input / output operations being required during index access.

[0026] As a result, there is currently no means to effectively handle lock contention on the leaf pages of an index (eg, an SQL index).

[0027] Embodiments of the present disclosure provide a means for efficiently handling lock contention for leaf pages of an index, such as an SQL index, by utilizing a buffer (referred to herein as an "index distribution queue buffer") for storing such index keys in a queue of buffers, as opposed to storing the index keys in the leaf page experiencing lock contention. When such a leaf page is no longer experiencing such lock contention, the appropriate index key is then removed from the index distribution queue buffer and stored in the leaf page based on a data structure (referred to herein as an "index leaf router map") that maps the index keys stored in the index distribution queue buffer to the appropriate leaf page of the index. A more detailed description of these and other features is provided below.

[0028] In some embodiments of the present disclosure, the present disclosure comprises a computer-implemented method, system, and computer program product for handling lock contention of an index (e.g., an SQL index). In one embodiment of the present disclosure, leaf pages of an index (e.g., an SQL index) are monitored for lock contention during an insert operation of an index key by a transaction. As used herein, a "lock contention" refers to any time when one process (transaction) attempts to obtain a "lock" on a leaf page of an index held by another process (transaction). As used herein, an "index" refers to an on-disk structure associated with a table or view that speeds up retrieval of rows from the table or view. In one embodiment, such an index stores a "key" or "index key" constructed from one or more columns in the table or view. As used herein, an "index key" refers to a key of an index (e.g., an SQL index) that allows a relational database management system to quickly and efficiently find a row or rows associated with a key value. Storing such a key value in an index is referred to herein as a "transaction." Furthermore, a "leaf page" of an index is the lowest level of the index where all keys for that index appear in sorted order. Upon detecting a lock contention for a leaf page, the next index key to be entered into such leaf page is routed to a queue in a buffer (referred to herein as the "index distribution queue buffer"). The index key stored in the queue of the index distribution queue buffer is then mapped to the particular leaf page experiencing the lock contention where the transaction originally attempted to store such index key.In one embodiment, such mapping is stored in a data structure referred to herein as an "index leaf router map," which stores a mapping of index keys stored in the queues of the index distribution queue buffer to leaf pages of an index. When such leaf pages no longer experience such lock contention, the appropriate index keys are then removed from the index distribution queue buffer and stored in the appropriate leaf pages based on the mapping in the index leaf router map. In this manner, lock contention for leaf pages of indexes, such as SQL indexes, is handled efficiently.

[0029] In the following description, numerous specific details are set forth to provide a thorough understanding of the present disclosure. However, it will be apparent to those skilled in the art that the present disclosure may be practiced without such specific details. In other instances, well-known circuits are shown in block diagram form so as not to obscure the present disclosure with unnecessary detail. For the most part, details regarding timing considerations and the like are omitted unless such details are necessary to obtain a complete understanding of the present disclosure and are within the skill of those skilled in the relevant art.

[0030] Referring now in detail to the drawings, Figure 1 illustrates a disclosed embodiment of a communication system 100 for practicing the principles of the present disclosure. The communication system 100 includes a computing device 101 connected to a relational database management system 102 (e.g., Structured Query Language (SQL Server)) via a network 103. As further shown in Figure 1, the relational database management system 102 is connected to a database 104.

[0031] Computing device 101 may be any type of computing device (e.g., a portable computing unit, a Personal Digital Assistant (PDA), a laptop computer, a mobile device, a tablet personal computer, a smart phone, a mobile telephone, a navigation device, a gaming unit, a desktop computer system, a workstation, an Internet appliance, etc.) configured with the ability to connect to network 103 and thereby communicate with other computing devices 101 and relational database management system 102. Note that both computing device 101 and a user of computing device 101 may be identified by element number 101.

[0032] Network 103 may be, for example, a local area network, a wide area network, a wireless wide area network, a circuit-switched telephone network, a Global System for Mobile Communications (GSM) network, a Wireless Application Protocol (WAP) network, a WiFi network, an IEEE 802.11 standard network, various combinations thereof, etc. Other networks, the descriptions of which are omitted herein for brevity, may also be used in conjunction with system 100 of FIG. 1 without departing from the scope of this disclosure.

[0033] In one embodiment, a user of the computing device 101 issues queries (e.g., SQL queries) to the relational database management system 102 (e.g., an SQL server) to update, delete, and request information from the database 104. For example, a user may issue an INSERT INTO query to add a new row of data to a table in the database 104. Such queries will be processed by the relational database management system 102, including storing and retrieving data as requested by the user.

[0034] In one embodiment, the relational database management system 102 is configured to maintain a database 104, such as a relational database. In one embodiment, the relational database management system 102 corresponds to a SQL Server configured to use Structured Query Language (SQL) to query and maintain the database 104.

[0035] In one embodiment, the relational database management system 102 is configured to efficiently handle lock contention for leaf pages of indexes, such as SQL indexes, by utilizing a buffer (referred to herein as an "index distribution queue buffer") for storing such index keys in a queue of buffers, as opposed to storing the index keys in the leaf page experiencing the lock contention. When such a leaf page no longer experiences such lock contention, the appropriate index key is then removed from the index distribution queue buffer and stored in the appropriate leaf page based on a data structure (referred to herein as an "index leaf router map") that maps index keys stored in the index distribution queue buffer to appropriate leaf pages of the index. A more detailed description of these and other features is provided below. Further, a description of the software components of the relational database management system 102 is provided below in conjunction with FIG. 2, and a description of the hardware configuration of the relational database management system 102 is provided further below in conjunction with FIG. 3.

[0036] System 100 is not limited in scope to any one particular network architecture and may include any number of computing devices 101, relational database management systems 102, networks 103, and databases 104.

[0037] A discussion of the software components used by the relational database management system 102 to efficiently handle lock contention on leaf pages of indexes, such as SQL indexes, is provided below in conjunction with FIG.

[0038] FIG. 2 is a diagram of software components of a relational database management system 102 for efficiently handling lock contention for leaf pages of indexes, such as SQL indexes, in accordance with an embodiment of the present disclosure.

[0039] Referring to FIG. 2 in conjunction with FIG. 1, the relational database management system 102 includes a monitoring engine 201 configured to monitor the lock state of a leaf page of an index (e.g., an SQL index) during an insert index key operation. As previously discussed, an insert index key operation into a leaf page of an index occurs when a query (e.g., an SQL query) requests adding data into the database 104, such as a new row of data into a table in the database 104. As used herein, an "index" refers to an on-disk structure associated with a table or view that speeds up retrieval of rows from the table or view. In one embodiment, such an index stores a "key" or "index key" constructed from one or more columns in the table or view. As used herein, an "index key" refers to a key of an index (e.g., an SQL index) that allows the relational database management system 102 to quickly and efficiently find a row or rows associated with a key value. Such index keys correspond to values ​​(e.g., 123242), variable characters (e.g., "Smith1"), and the like. Storing such a key value in the index is referred to herein as a "transaction."

[0040] Further, as previously discussed, in one embodiment, index keys are stored in a B-tree structure, where such a B-tree index includes a multi-level tree structure that divides the database into fixed-size blocks or pages. This tree at each level can be used to link the pages together via address locations, allowing one page (known as a node or interior page) to reference another page at a leaf page at the lowest level. One page is typically the start or "root" of the tree, where a search for a particular key begins and follows a path that ends at a leaf. That is, the "leaf pages" of an index are the lowest level of the index where all the keys for that index are displayed in sorted order.

[0041] In one embodiment, the monitoring engine 201 monitors for lock contention on leaf pages in an index during an insert operation of an index key into such leaf page. As used herein, a "lock contention" refers to a transaction attempting to simultaneously insert a key value into a leaf page of an index. That is, a "lock contention" occurs whenever a process (transaction) attempts to acquire a "lock" held by another process (transaction). In one embodiment, a "lock" on a leaf page to prevent other processes (transactions) from utilizing the leaf page may be achieved by a "page level lock". As used herein, a "page level lock" refers to locking the entire leaf page. Alternatively, a process (transaction) may lock a row of a leaf page, such as via a "row lock + page latch". As used herein, "row lock" refers to locking a particular row of a leaf page, and "page latch" as used herein refers to a mechanism managed by the relational database management system 102 (e.g., SQL Server) rather than by a user, in which the relational database management system 102 places a "latch" or "hold" on a leaf page to prevent access. As used herein, "row lock + page latch" refers to a combination of "row lock" and "page latch."

[0042] In one embodiment, the monitoring engine 201 detects lock contention based on the length of a page-level lock wait queue. As used herein, a "page-level lock wait queue" refers to a queue that stores various page-level locks (locks placed for various leaf pages) to be implemented. For example, such lock contention may be based on a threshold percentage of the total length of the queue. In one embodiment, such threshold percentage may be user-specified.

[0043] In one embodiment, the monitoring engine 201 detects lock contention based on the length of a row-level lock wait queue. As used herein, a "row-level lock wait queue" refers to a queue that stores various row-level locks (locks placed for various rows within a leaf page) to be implemented. For example, such lock contention may be based on a threshold percentage of the total length of the queue. In one embodiment, such threshold percentage may be user-specified.

[0044] In one embodiment, the monitoring engine 201 detects lock contention based on the length of a latch wait queue. As used herein, a "latch wait queue" refers to a queue that stores various page latches (latches located for various leaf pages) to be implemented. For example, such lock contention may be based on a threshold percentage of the total length of the queue. In one embodiment, such threshold percentage may be user-specified.

[0045] Examples of software tools utilized by the monitoring engine 201 to perform such monitoring include, but are not limited to, SolarWinds® Database Performance Analyzer, Paessler® PRG Network Monitor, SQL Power Tools, Redgate® SQL Monitor, Nagios®, Opsview®, and the like.

[0046] Additionally, the monitoring engine 201 is configured to detect the level of lock contention on the leaf pages of an index, e.g., to determine whether it is below a threshold level, which may be user-specified. In one embodiment, the degree or level of lock contention on the leaf pages of an index is determined by the monitoring engine 201 based on the number of transactions attempting to store index keys on the leaf pages, as well as based on the page free size information. As used herein, "page free size information" refers to the amount of memory space available on the leaf pages for storing index keys. In one embodiment, each leaf page of an index (e.g., an SQL index) is assigned a particular size (e.g., 3 KB) by an expert or the like. In one embodiment, the monitoring engine 201 is configured to track the amount of memory used by the storage of index keys, and thus can determine the amount of memory space remaining for storing additional index keys. Examples of software tools utilized by the monitoring engine 201 to track memory usage of the leaf pages of an index (e.g., an SQL index) include, but are not limited to, SQLShack, ApexSQL by Quest®, and the like.

[0047] In one embodiment, a degree or level of lock contention in a leaf page may be determined based on such memory usage of a leaf page of an index and the number of index keys to be written to the leaf page. For example, if the number of index keys to be written to a leaf page requires memory space that is more than 50% of the remaining available memory space in the leaf page, the leaf page may be said to be experiencing lock contention. On the other hand, if the number of index keys to be written to a leaf page requires memory space that is less than 25% of the remaining available memory space in the leaf page, the leaf page may be said to be experiencing a low level of lock contention. As used herein, a "low level" of lock contention refers to a leaf page that is considered to be not experiencing lock contention.

[0048] The relational database management system 102 further comprises a buffer engine 202 configured to create a buffer, referred to herein as an "index distribution queue buffer." In one embodiment, the index distribution queue buffer is configured to include one or more queues, each of which stores one or more index keys that map to a particular leaf page, as discussed further below. In one embodiment, the index keys stored in the queues of the buffer are synchronized via compare-and-swap. As used herein, "compare-and-swap" refers to an atomic instruction used in multithreading to achieve synchronization. It compares the contents of a memory location with a given value, and only if they are the same, modifies the contents of the memory location to a new given value.

[0049] In one embodiment, buffer engine 202 adds or removes queues in the index distribution queue buffer based on the degree of lock contention on the leaf pages of an index (e.g., an SQL index). For example, in one embodiment, buffer engine 202 creates a new queue in the index distribution queue buffer when a queue reaches a threshold percentage (e.g., 90%) of its maximum queue length during a situation where other queues in the index distribution queue buffer cannot handle the storage of additional index keys that are being attempted to be stored on the leaf pages of an index that is experiencing lock contention.

[0050] In one embodiment, the number of index keys stored in a queue may be tracked via a "queue count" maintained by buffer engine 202. When the queue count reaches zero, indicating that the queue is no longer storing any index keys, such a queue may be recycled; that is, the queue's data structure in the index distribution queue buffer is deleted, and the memory previously utilized by the queue's deleted data structure is now free for subsequent use, such as for new queues that are later added to the index distribution queue buffer.

[0051] Examples of software tools utilized by the buffer engine 202 to add or remove queues in the index distribution queue buffer include, but are not limited to, ManageEngine® OpManager, SolarWinds® Network Performance Monitor, Redis, Amazon® SQS, etc.

[0052] Additionally, the relational database management system 102 includes a routing engine 203 configured to route index keys to queues of the index distribution queue buffer in response to the monitoring engine 201 detecting a lock condition on a leaf page.

[0053] In one embodiment, routing engine 203 is configured to route index keys to queues of an index distribution queue buffer in terms of certain rules, such as modular hashing. In one embodiment, routing engine 203 is configured to store index keys only in queues of an index distribution queue buffer that have at least a threshold percentage (e.g., 5%) of their capacity available to store index keys. In one embodiment, such threshold percentage may be user-specified.

[0054] In one embodiment, the routing engine 203 is configured to remove index keys from the index distribution queue buffer and asynchronously insert them into the appropriate leaf pages based on a data structure (mapping of index keys stored in the index distribution queue buffer to appropriate leaf pages of the index) in response to detecting that the level of lock contention on the leaf pages is below a threshold level. Such detection is performed by the monitoring engine 201, as discussed above.

[0055] In one embodiment, the routing engine 203 is configured to, in response to detecting a leaf page split, triggering a system checkpoint for the leaf page, and receiving a SELECT, UPDATE, or DELETE statement involving the leaf page, remove index keys from the index distribution queue buffer and synchronously insert them into the appropriate leaf page based on a data structure (mapping of index keys stored in the index distribution queue buffer to appropriate leaf pages of the index). Such detection is discussed further below in connection with the detector engine 205.

[0056] As used herein, a "split" of a leaf page refers to a situation when there is not enough memory space to add new data (e.g., new rows) that is required to be on a leaf page, and as a result, the leaf page must split. When a split occurs, the leaf page may be split into two pages, each with approximately half of the rows of the original leaf page.

[0057] As used herein, a "system checkpoint" for a leaf page refers to a test operation that validates data, such as index keys, obtained from a leaf page by comparing the data to a baseline copy.

[0058] A SELECT statement, such as an SQL SELECT statement, is used to select data from database 104. An UPDATE statement, such as an SQL UPDATE statement, is used to modify existing records in a table of database 104. A DELETE statement, such as an SQL DELETE statement, is used to delete existing records in a table of database 104.

[0059] Examples of software tools utilized by the routing engine 203 to route index keys from the index distribution queue buffer to the appropriate leaf page of an index (e.g., an SQL index) include, but are not limited to, ApexSQL by Quest®, PostgreSQL®, Snowflake®, etc.

[0060] In addition, the relational database management system 102 includes a mapping engine 204 configured to build a data structure (e.g., a table) referred to herein as an “index-leaf-router map.” In one embodiment, such a data structure is stored in a storage device (e.g., memory, disk unit) of the relational database management system 102.

[0061] As discussed above, the "index leaf router map" maps index keys stored in the index distribution queue buffer to appropriate leaf pages of the index. In one embodiment, the mapping engine 204 maps index keys stored in various memory locations of the queues of the index distribution queue buffer to various leaf pages based on such memory locations. For example, a key index may be stored in memory location Q11 of queue #1. Such memory location may then be stored in an index leaf router map associated with a particular leaf page (e.g., leaf page #5). In one embodiment, the particular leaf page is based on a query received by the relational database management system 102, in which the query results in the addition of a new data row to a table of the database 104, thereby resulting in an index key to be stored in such leaf page. Instead of storing such index key in this leaf page, it is temporarily stored in the index distribution queue buffer until the leaf page has sufficient capacity to store the index key. To keep track of which leaf page should receive which index key, such information is maintained in an index leaf router map by the mapping engine 204.

[0062] In one embodiment, the mapping between the memory locations of index keys in the queue of the index distribution queue buffer and the identifiers of the various leaf pages of an index (e.g., an SQL index) is synchronized via compare-and-swap.

[0063] Examples of software tools utilized by the mapping engine 204 to map index keys stored in the index distribution queue buffer to the appropriate leaf pages of the index include, but are not limited to, IBM® Db2, ApexSQL by Quest®, and the like.

[0064] Additionally, the relational database management system 102 comprises a detector engine 205 configured to detect leaf page splits, the triggering of a system checkpoint on a leaf page, and the receipt of a SELECT, UPDATE, or DELETE statement involving a leaf page.

[0065] As discussed above, as used herein, a "split" of a leaf page refers to a situation when there is not enough memory space to add new data (e.g., new rows) that is required to be on a leaf page, and as a result, the leaf page must split. When a split occurs, the leaf page may be split into two pages, each with approximately half of the rows of the original leaf page. As a result, the detector engine 205 detects a leaf page split upon the creation of a new leaf page to store half of the data stored in the original leaf page.

[0066] Furthermore, as discussed above, as used herein, a "system checkpoint" for a leaf page refers to a test operation that validates data, such as index keys, obtained from the leaf page by comparing the data to a baseline copy. In one embodiment, the detector engine 205 detects such a system checkpoint based on detecting the issuance of a checkpoint by the database engine 206 (e.g., a SQL Server database engine) of the relational database management system 102.

[0067] In one embodiment, the database engine 206 is configured to periodically issue checkpoints (e.g., automatic, indirect, manual, and internal types of checkpoints) to verify the data in the leaf pages. In one embodiment, the issuance of such checkpoints is detected by the detector engine 205 based on a checkpoint command issued by the database engine 206.

[0068] Additionally, as discussed above, SELECT statements, such as SQL SELECT statements, are used to select data from the database 104. UPDATE statements, such as SQL UPDATE statements, are used to modify existing records in tables of the database 104. DELETE statements, such as SQL DELETE statements, are used to delete existing records in tables of the database 104. In one embodiment, the detector engine 205 is configured to detect receipt of such statements based on identifying such statements in a query received by the relational database management system 102 from the computing device 101. In one embodiment, the detector engine 205 utilizes natural language processing to identify such statements in a query, and such terms are stored in a data structure stored by an expert. In one embodiment, such data structure is stored in a storage device (e.g., memory, disk unit) of the relational database management system 102.

[0069] In one embodiment, the detector engine 205 is configured to detect a sequential insertion pattern of index keys in a leaf page during an index split. As discussed above, when an index split occurs, a leaf page may be split into two pages, each with roughly half of the rows of the original leaf page. In one embodiment, if a sequential pattern of index keys (sequential movement pattern) is entered in such a leaf page, the detector engine 205 asynchronously pre-allocates multiple leaf pages of the index to reduce possible lock contention scenarios. Since the sequential pattern of index keys may continue in such leaf pages, it can be said that lock contention is more likely to occur in such a situation. In one embodiment, such sequential movement patterns are detected by the detector engine 205 by predicting key values ​​as non-leaf key values ​​for those new pre-allocated leaf pages using high / low key values ​​from previous leaf pages.

[0070] Further description of these and other features is provided below in connection with a discussion of methods for handling lock contention on leaf pages of indexes (SQL indexes).

[0071] Prior to discussing the method for handling lock contention on leaf pages of an index (SQL index), a description of the hardware configuration of the relational database management system 102 (FIG. 1) is provided below with reference to FIG.

[0072] Reference is now made to FIG. 3, which illustrates an embodiment of the present disclosure of a hardware configuration for relational database management system 102 (FIG. 1) that is representative of a hardware environment for practicing the present disclosure.

[0073] The relational database management system 102 includes a processor 301 connected to various other components by a system bus 302. An operating system 303 executes on the processor 301 and provides control of and coordinates the functions of the various components of FIG. 3. Applications 304 according to the principles of the present disclosure execute in conjunction with the operating system 303 and provide calls to the operating system 303, where the calls implement various functions or services to be performed by the applications 304. The applications 304 may include, for example, a monitoring engine 201 (FIG. 2), a buffer engine 202 (FIG. 2), a routing engine 203 (FIG. 2), a mapping engine 204 (FIG. 2), a detector engine 205 (FIG. 2), and a database engine 206 (FIG. 2). Additionally, the applications 304 may include programs for handling lock contention for leaf pages of an index (e.g., an SQL index), for example, as discussed further below in connection with FIGS. 4-11.

[0074] Referring again to FIG. 3, Read-Only Memory ("ROM") 305 is connected to system bus 302 and includes a Basic Input / Output System ("BIOS") that controls certain basic functions of relational database management system 102. Random Access Memory ("RAM") 306 and disk adapter 307 are also connected to system bus 302. Note that software components including operating system 303 and applications 304 may be loaded into RAM 306, which may be the main memory of relational database management system 102 for execution. Disk adapter 307 may be an Integrated Drive Electronics ("IDE") adapter that communicates with disk unit 308, e.g., a disk drive. Note that, as discussed further below in connection with FIGS. 4-11, programs for handling lock contention for leaf pages of an index (e.g., an SQL index) may reside in disk unit 308 or in application 304.

[0075] Relational database management system 102 may further include a communications adapter 309 coupled to bus 302. Communications adapter 309 interconnects bus 302 with an external network (e.g., network 103 of FIG. 1) for communication with other devices, such as computing device 101 (FIG. 1).

[0076] In one embodiment, the application 304 of the relational database management system 102 includes the following software components: monitoring engine 201, buffer engine 202, routing engine 203, mapping engine 204, detector engine 205, and database engine 206. In one embodiment, such components may be implemented in hardware, in which case such hardware components would be connected to the bus 302. The functions discussed above that are performed by such components are not general purpose computer functions. As a result, the relational database management system 102 is a specific machine that is the result of implementing specific, non-general purpose computer functions.

[0077] In one embodiment, the functionality of such software components of the relational database management system 102 (e.g., monitor engine 201, buffer engine 202, routing engine 203, mapping engine 204, detector engine 205, and database engine 206), including functionality for handling lock contention on leaf pages of an index, may be embodied in application specific integrated circuits.

[0078] The present invention may be a system, method and / or computer program product at any possible level of technical detail integration. The computer program product may include a computer readable storage medium or media having computer readable program instructions for causing a processor to carry out aspects of the present invention.

[0079] A computer-readable storage medium may be a tangible device that can hold and store instructions for use by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the above. A non-exhaustive list of more specific examples of computer-readable storage media includes the following: portable computer diskettes, hard disks, random access memories (RAMs), read-only memories (ROMs), erasable programmable read-only memories (EPROMs or flash memories), static random access memories (SRAMs), portable compact disk read-only memories (CD-ROMs), digital versatile disks (DVDs), memory sticks, floppy disks, punch cards, or mechanically encoded devices such as ridge structures in grooves with instructions recorded therein, and any suitable combination of the above. As used herein, a computer-readable storage medium should not be construed as a transitory signal per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission medium (e.g., light pulses passing through a fiber optic cable), or electrical signals transmitted over wires.

[0080] The computer-readable program instructions described herein may be downloaded from a computer-readable storage medium to the respective computing / processing device or to an external computer or storage device via a network, such as, for example, the Internet, a local area network, a wide area network, and / or a wireless network. The network may comprise copper transmission cables, optical transmission fiber, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and transfers the computer-readable program instructions to a computer-readable storage medium in the respective computing / processing device for storage.

[0081] The computer readable program instructions for carrying out the operations of the present invention may be assembler instructions, instruction set architecture (ISA) instructions, machine instructions, machine dependent instructions, microcode, firmware instructions, state setting data, configuration data for an integrated circuit, or may be either source code or object code written in any combination of one or more programming languages, including object oriented programming languages ​​such as Smalltalk® or C++, and procedural programming languages ​​such as the “C” programming language or similar programming languages. The computer readable program instructions may execute entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection may be to an external computer (e.g., through the Internet using an Internet Service Provider). In some embodiments, electronic circuitry including, for example, a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA) may execute computer readable program instructions to personalize the electronic circuitry by utilizing state information of the computer readable program instructions to perform aspects of the invention.

[0082] Aspects of the present invention are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer readable program instructions.

[0083] These computer readable program instructions may be provided to a processor of a computer, or other programmable data processing apparatus to produce a machine whereby the instructions, executed via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions / acts specified in one or more blocks of the flowcharts and / or block diagrams. These computer readable program instructions may also be stored in a computer readable storage medium that may direct a computer, programmable data processing apparatus, and / or other device to function in a particular manner, such that the computer readable storage medium on which the instructions are stored has an article of manufacture including instructions that implement aspects of the functions / acts specified in one or more blocks of the flowcharts and / or block diagrams.

[0084] Also, computer readable program instructions may be loaded into a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be executed on the computer, other programmable apparatus, or other device to generate a computer-implemented process, whereby the instructions executing on the computer, other programmable apparatus, or other device implement the functions / acts specified in one or more blocks of the flowcharts and / or block diagrams.

[0085] The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowcharts or block diagrams may represent a module, segment, or portion of instructions comprising one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions noted in the blocks may occur in a different order than that noted in the figures. For example, two blocks shown in succession may in fact be realized as one step, and may be executed simultaneously, substantially simultaneously, partially or fully in a time-overlapping manner, or the blocks may possibly be executed in reverse order depending on the functionality involved. It should also be noted that each block in the block diagrams and / or flowchart diagrams, and combinations of blocks in the block diagrams and / or flowchart diagrams, may be implemented by a special-purpose hardware-based system that performs the specified functions or actions, or executes a combination of special-purpose hardware and computer instructions.

[0086] As described above, an SQL query, such as an SQL INSERT INTO statement, may be received and processed by a relational database management system (e.g., an SQL server). Such a query (e.g., an SQL INSERT INTO statement) may be used to add a new row of data to a table in a database. When such a scenario occurs, the associated index defined on this table needs to be updated. An index is an on-disk structure associated with a table or view that speeds up retrieval of rows from the table or view. An index typically includes a key constructed from one or more columns in the table or view. These keys are stored in a structure (a B-tree) that allows the relational database management system to quickly and efficiently find the row or rows associated with the key value. As a result, when a new row of data is added to a table in a database, the index needs to be updated to include the key value associated with such row of data. Storing such a key value in an index is referred to herein as a "transaction." A B-tree index creates a multi-level tree structure that divides the database into fixed-size blocks or pages. This tree at each level can be used to link the pages together via their address locations, allowing one page (known as a node or interior page) to reference another page at a leaf page at the lowest level. One page is usually the beginning or "root" of the tree, where a search for a particular key begins and follows a path that ends at a leaf. That is, the leaf pages of an index are the lowest level of the index where all the keys for that index appear in sorted order. Most pages in such a structure are leaf pages that ultimately reference a particular table row. Sometimes, multiple different transactions are trying to insert key values ​​into the leaf pages of an index (e.g., an SQL index) at the same time, resulting in "lock contention" that adversely affects performance.A "lock contention" occurs whenever one process (transaction) attempts to acquire a "lock" held by another process (transaction). In an attempt to address lock contention, such transactions may be handled in a randomized manner. However, processing of queries, such as SQL queries, associated with such transactions may suffer performance. In yet another attempt to address lock contention, the minimum page size of leaf pages of an index may be increased. However, lock contention may only be reduced slightly. Furthermore, increasing the minimum page size of leaf pages of an index may result in more database input / output operations being required during index access. As a result, currently there is no means to effectively handle lock contention on leaf pages of an index (e.g., an SQL index).

[0087] Embodiments of the present disclosure provide a means for effectively handling lock contention for leaf pages of an index, such as an SQL index, by utilizing a buffer (referred to herein as an "index distribution queue buffer") for storing such index keys in a queue of buffers, as opposed to storing the index keys in the leaf pages experiencing lock contention. When such leaf pages no longer experience lock contention, the appropriate index keys are then removed from the index distribution queue buffer and stored in the appropriate leaf pages based on a data structure (referred to herein as an "index leaf router map") that maps index keys stored in the index distribution queue buffer to appropriate leaf pages of the index. A description of these and other features is discussed below in conjunction with FIGS. 4-11. FIG. 4 is a flow chart of a method for handling lock contention for leaf pages of an index. FIG. 5 illustrates monitoring for lock contention for leaf pages of an index during an insert operation of the index key in the leaf page. FIG. 6 illustrates routing of index keys from a transaction involving an attempt to store an index key in a leaf page experiencing lock contention to a queue of an index distribution queue buffer. FIG. 7 is a flow chart of a method for handling storage of additional index keys. Figure 8 is a flow chart of a method for asynchronously inserting an index key into an appropriate leaf page that previously experienced a lock contention. Figure 9 is a flow chart of a method for synchronously inserting an index key into a leaf page in response to detecting an index split on the leaf page, a system checkpoint involving the leaf page, or receipt of a SELECT, UPDATE, or DELETE statement involving the leaf page. Figure 10 is a flow chart of a method for preallocating leaf pages during an index split if a potential future lock contention is detected. Figure 11 illustrates preallocating leaf pages during an index split.

[0088] As mentioned above, FIG. 4 is a flowchart of a method 400 for handling lock contention on leaf pages of an index (eg, an SQL index) according to an embodiment of the present disclosure.

[0089] Referring to FIG. 4 in conjunction with FIGS. 1-3, in operation 401, the monitoring engine 201 of the relational database management system 102 monitors for lock contention on a leaf page of an index (eg, an SQL index) during an index key insert operation by a transaction.

[0090] In operation 402, the monitoring engine 201 of the relational database management system 102 determines whether a lock conflict has been detected.

[0091] As previously discussed, an insert operation of an index key into a leaf page of an index occurs when a query (e.g., an SQL query) requests adding data into the database 104, such as a new row of data into a table in the database 104. As used herein, an "index" refers to an on-disk structure associated with a table or view that speeds up retrieval of rows from the table or view. In one embodiment, such an index stores a "key" or "index key" constructed from one or more columns in the table or view. As used herein, an "index key" refers to a key of an index (e.g., an SQL index) that allows the relational database management system 102 to quickly and efficiently find the row or rows associated with a key value. Such index keys correspond to values ​​(e.g., 123242), variant characters (e.g., "Smith1"), etc. Storing such a key value in an index is referred to herein as a "transaction."

[0092] Further, as previously discussed, in one embodiment, index keys are stored in a B-tree structure, where such a B-tree index includes a multi-level tree structure that divides the database into fixed-size blocks or pages. This tree at each level can be used to link the pages together via address locations, allowing one page (known as a node or interior page) to reference another page at a leaf page at the lowest level. One page is typically the start or "root" of the tree, where a search for a particular key begins and follows a path that ends at a leaf. That is, the "leaf pages" of an index are the lowest level of the index where all the keys for that index are displayed in sorted order.

[0093] In one embodiment, the monitoring engine 201 monitors for lock contention on leaf pages in an index during an insert operation of an index key into such leaf page. As used herein, a "lock contention" refers to a transaction attempting to simultaneously insert a key value into a leaf page of an index. That is, a "lock contention" occurs whenever a process (transaction) attempts to acquire a "lock" held by another process (transaction). In one embodiment, a "lock" on a leaf page to prevent other processes (transactions) from utilizing the leaf page may be achieved by a "page level lock". As used herein, a "page level lock" refers to locking the entire leaf page. Alternatively, a process (transaction) may lock a row of a leaf page, such as via a "row lock + page latch". As used herein, "row lock" refers to locking a particular row of a leaf page, and "page latch" as used herein refers to a mechanism managed by the relational database management system 102 (e.g., SQL Server) rather than by a user, in which the relational database management system 102 places a "latch" or "hold" on a leaf page to prevent access. As used herein, "row lock + page latch" refers to a combination of "row lock" and "page latch."

[0094] Examples of software tools utilized by the monitoring engine 201 to perform such monitoring include, but are not limited to, SolarWinds® Database Performance Analyzer, Paessler® PRG Network Monitor, SQL Power Tools, Redgate® SQL Monitor, Nagios®, Opsview®, and the like.

[0095] An example of monitoring by the monitoring engine 201 for lock contention on a leaf page of an index during an insert operation of an index key into the leaf page is discussed below in connection with FIG.

[0096] Referring to FIG. 5, FIG. 5 illustrates monitoring for lock contention on a leaf page of an index during an insert operation of an index key into the leaf page according to an embodiment of the present disclosure.

[0097] As shown in FIG. 5, multiple transactions 501A-501C (identified in FIG. 5 as "transaction #X", "transaction #Y", and "transaction #Z", respectively) attempt to store an index key in a leaf page 502 of an index that already stores a certain number of index keys 503 (identified in FIG. 5 as "key #1", "key #2", "key #3", ... "key #N", where N is a positive integer). Transactions 501A-501C may be collectively or individually referred to as multiple transactions 501 or a single transaction 501, respectively. Index keys 503 may be collectively or individually referred to as multiple index keys 503 or a single index key 503, respectively.

[0098] When each transaction 501 attempts to store an index key 503 in a leaf page, such as leaf page 502, the transaction 501 applies either a page lock or a row lock plus a page latch. The page or row locks to be implemented are stored in a "page / row level lock wait queue" 504 that contains a list of page / row locks to be implemented (identified in FIG. 5 as "lock #n", "lock #m", "lock #x", "lock #y", and "lock #z"). Note that as used herein, the symbol " / " means "or". Thus, a "page / row" level lock wait queue refers to a page level lock wait queue or a row level lock wait queue.

[0099] In one embodiment, the monitoring engine 201 detects lock contention based on the length of the page / row level lock wait queue 504. In one embodiment, such lock contention may be based on a threshold percentage of the total length of the queue 504. In one embodiment, such threshold percentage may be user-specified.

[0100] 5, in one embodiment, the monitoring engine 201 detects lock contention based on the length of a latch wait queue 505 (e.g., identified in FIG. 5 as “latch #x”, “latch #y”, “latch #z”, ... “latch #y”) that stores various page latches (latches located for various leaf pages) to be implemented. For example, such lock contention may be based on a threshold percentage of the total length of the queue 505. In one embodiment, such threshold percentage may be user-specified.

[0101] Further, as shown in FIG. 5, based on such monitoring by the monitoring engine 201, the index key 503 will be routed to an index distribution queue buffer 506, as discussed in more detail below.

[0102] Additionally, as shown in FIG. 5, index distribution queue buffer 506 includes queues 507A-507N (identified in FIG. 5 as “Queue #1”, “Queue #2”, ... “Queue #N”, where N is a positive integer). Queues 507A-507N may be referred to collectively or individually as queues 507 or queue 507, respectively. Each queue 507 stores one or more index keys 503. Further discussion regarding the storage of index keys 503 in queues 507 of index distribution queue buffer 506 is provided further below.

[0103] 5 shows a particular number of entries in queues 504, 505, it should be noted that FIG. 5 may include any number of entries in queues 504, 505. Similarly, buffer 506 may include any number of queues 507, and each queue 507 may include any number of entries for storing any number of index keys 503. Furthermore, leaf page 502 may store any number of index keys 503. It should be noted that element number 503 refers to those index keys stored in leaf pages, such as leaf page 502, as well as those index keys stored in queues 507 of buffer 506.

[0104] Returning to operation 402 in FIG. 4 in conjunction with FIGS. 1 to 3 and 5, if no lock conflict is detected, the monitoring engine 201 of the relational database management system 102 continues to monitor for lock conflicts on the leaf page of the index (e.g., an SQL index) during the index key insert operation by transaction 501 in operation 401.

[0105] However, if a lock conflict is detected, in operation 403, the routing engine 203 of the relational database management system 102 routes the next index key 503 (intended to be stored in the leaf page identified as exhibiting a lock conflict) to a queue 507 of the index distribution queue buffer 506, as shown in FIG. 6, thereby moving the lock conflict to a different leaf page.

[0106] Referring to FIG. 6, FIG. 6 illustrates routing of index key 503 from a transaction involving an attempt to store index key 503 in a leaf page experiencing a lock conflict to queue 507 (FIG. 5) of index distribution queue buffer 506 (FIG. 5), where the stored index key 503 is mapped to the leaf page experiencing the lock conflict, in accordance with an embodiment of the present disclosure.

[0107] As shown in FIG. 6, transactions 601A-601D (labeled in FIG. 6 as “Transaction #1”, “Transaction #2”, “Transaction #3”, and “Transaction #4”, respectively) attempt to store index key 503 (labeled in FIG. 6 as “K51”, “K52”, and “K61” for transaction 601A, “K53”, “K54”, and “K62” for transaction 601B, “K55”, “K63”, and “K65” for transaction 601C, and “K56”, “K64”, and “K66” for transaction 601D) in leaf pages 602A-602B (identified in FIG. 6 as “Leaf #5” and “Leaf #6”, respectively) that are experiencing a lock conflict. As a result, as shown in FIG. 6, routing engine 203 routes such index keys 503 to various queues 507 of index distribution queue buffer 506. Additionally, as shown in FIG. 6, by routing such index keys 503 to various queues 507 of index distribution queue buffer 506, the area of ​​lock contention may be moved to another leaf page, such as leaf page 602C (identified in FIG. 6 as "Leaf #7"). For completeness, note that in an index (e.g., an SQL index), each of the leaf pages shown in FIG. 6 (602A-602D, where leaf page 602D is identified in FIG. 6 as "Leaf #4") is a child of a non-leaf page 603 (identified in FIG. 6 as "Non-leaf #2") that is one or more levels below the root node (not shown in FIG. 6) (located at an intermediate level in the index's (B-tree) structure). Transactions 601A-601D may be collectively or individually referred to as transactions 601 or a single transaction 601. Leaf pages 602A-602D may be collectively or individually referred to as leaf pages 602 or a single leaf page 602.6 shows four transactions 601, note that any number of transactions 601 may be attempting to store an index key 503 on any number of leaf pages 602. Furthermore, an index (e.g., an SQL index) may include any number of leaf pages 602 and non-leaf pages 603.

[0108] In one embodiment, routing engine 203 routes such index keys 503 to queues 507 of index distribution queue buffer 506 in terms of a particular rule (e.g., a hash, such as modular hashing, as shown in FIG. 6, where hash value=key value modulus 16). For example, based on applying such a particular rule, as shown in FIG. 6, index key K51 is stored in queue position Q11 of queue 507A, index key K61 is stored in queue position Q12 of queue 507A, index key K54 is stored in queue position Q13 of queue 507A, and index key K63 is stored in queue position Q14 of queue 507A. Similarly, as shown in Figure 6, index key K62 is stored in queue position Q21 of queue 507B, index key K52 is stored in queue position Q22 of queue 507B, index key K66 is stored in queue position Q23 of queue 507B, and index key K53 is stored in queue position Q24 of queue 507B. Furthermore, as shown in Figure 6, index keys K55, K64, K65, and K56 are stored in queue 507N.

[0109] In one embodiment, index keys 503 stored in queues 507 of index distribution queue buffer 506 are synchronized via compare-and-swap. As used herein, "compare-and-swap" refers to an atomic instruction used in multithreading to achieve synchronization. It compares the contents of a memory location with a given value, and only if they are the same, modifies the contents of that memory location to a new given value. For example, in one embodiment, the queue count, queue space used, and queue tail pointer may be used to provide information related to the structure of queues 507 in index distribution queue buffer 506 used in the "compare-and-swap" process.

[0110] Returning to Figure 4 in conjunction with Figures 1-3 and 5-6, in operation 404, mapping engine 204 of relational database management system 102 maps index key 503 (e.g., "K51") stored in queue 507 (e.g., queue 507A) of index distribution queue buffer 506 to a particular leaf page 602 (e.g., leaf page 602A) experiencing a lock contention where transaction 601 (e.g., transaction 601A) originally attempted to store index key 503 (e.g., "K51"). In one embodiment, such mapping is stored by mapping engine 204 in a data structure referred to herein as an "index leaf router map" 604, as shown in Figure 6.

[0111] Referring again to Figure 6, index leaf router map 604 stores a mapping of index keys 503 stored in queues 507 of index distribution queue buffer 506 to particular leaf pages 602 of an index (e.g., an SQL index). For example, the storage location identifiers of index keys 503 (e.g., queue positions Q11, Q13, Q22, Q24, Q16_1, Q16_4) are mapped to leaf page 602A (identified in Figure 6 as "Leaf #5") as shown in Figure 6. Similarly, the storage location identifiers of index keys 503 (e.g., queue positions Q12, Q14, Q21, Q23, Q16_2, Q16_3) are mapped to leaf page 602B (identified in Figure 6 as "Leaf #6") as shown in Figure 6.

[0112] In one embodiment, the index leaf router map 604 also stores page free size information 605A-605B of such leaf pages 602 (e.g., leaf pages 602A-602B, respectively), as shown in FIG. 6. Herein, the "page free size information" 605A-605B may be collectively or individually referred to as page free size information 605. As used herein, such page free size information 605 refers to the amount of memory space available in the leaf pages 602 for storing index keys 503. As previously discussed, in one embodiment, the monitoring engine 201 is configured to track the amount of memory used by the storage of index keys 503, and thus can determine the amount of memory space remaining for storing additional index keys 503.

[0113] Further, as discussed above, in one embodiment, the mapping between the memory locations of index keys 503 in the queues 507 of the index distribution queue buffer 506 and the identifiers of the various leaf pages 602 of an index (e.g., an SQL index) is synchronized via compare-and-swap by the mapping engine 204.

[0114] In contrast to storing index keys 503 in leaf pages 602 that are experiencing lock contention, after routing such index keys 503 to queues 507 in index distribution queue buffer 506, the queues 507 in index distribution queue buffer 506 can be dynamically added / removed based on the degree of lock contention experienced by the leaf pages 602 of the index.

[0115] For example, in one embodiment, the buffer engine 202 dynamically adds or removes queues 507 in the index distribution queue buffer 506 based on the degree of lock contention on the leaf pages 602 of an index (e.g., an SQL index). As discussed above, in one embodiment, the degree or level of lock contention on the leaf pages of an index is determined by the monitor engine 201 based on the number of transactions attempting to store index keys 503 on the leaf pages 602, as well as based on the page free size information 605. If the number of queues 507 in the index distribution queue buffer 506 needs to be increased to store additional new index keys 503, the buffer engine 202 dynamically adds queues 507 to the index distribution queue buffer 506. Conversely, if the queues 507 in the index distribution queue buffer 506 are oversupplied to handle the current degree of lock contention on the leaf pages 602 of the index, the buffer engine 202 dynamically removes or removes queues 507 in the index distribution queue buffer 506.

[0116] For example, when a queue 507 of the index distribution queue buffer 506 reaches a threshold percentage of the maximum queue length, the buffer engine 202 of the relational database management system 102 may create a new queue 507 to handle the storage of the additional index keys 503 if no other queues 507 exist to handle any additional storage of the index keys 503, as discussed below in connection with FIG. 7.

[0117] FIG. 7 is a flowchart of a method 700 for handling storage of additional index keys 503 by creating a new queue 507 in the index distribution queue buffer 506 when no other queues 507 exist to handle the storage of these additional index keys 503, in accordance with an embodiment of the present disclosure.

[0118] Referring to FIG. 7 in conjunction with FIGS. 1-3 and 5-6, in operation 701, the buffer engine 202 of the relational database management system 102 determines whether a queue 507 (e.g., queue 507A) in the index distribution queue buffer 506 has reached a threshold percentage of the maximum queue length, such as during a situation where other queues 507 in the index distribution queue buffer 506 lack capacity to store additional index keys 503.

[0119] In one embodiment, such threshold percentages may be user-specified. In one embodiment, information regarding the structure of index distribution queue buffer 506, including its queues 507, may be stored in a data structure that may reside in a storage device (e.g., memory 305, disk units 308) of relational database management system 102. In one embodiment, such information includes the maximum length of queue 507, including a defined threshold percentage of that maximum queue length at which additional queues 507 should be created by buffer engine 202.

[0120] If there are no queues 507 in the index distribution queue buffer 506 that have reached the threshold percentage of the maximum queue length, the buffer engine 202 continues in operation 701 to determine whether any queues 507 in the index distribution queue buffer 506 have reached the threshold percentage of the maximum queue length.

[0121] However, if there is a queue 507 (e.g., queue 507A) in the index distribution queue buffer 506 that has reached a threshold percentage of the maximum queue length, such as during a situation where other queues 507 in the index distribution queue buffer 506 lack the capacity to store additional index keys 503, then in operation 702, the buffer engine 202 of the relational database management system 102 creates a new queue 507 in the index distribution queue buffer 506.

[0122] In operation 703, the routing engine 203 of the relational database management system 102 routes the newly incoming index key 503 to the newly created queue 507, as discussed above.

[0123] Furthermore, as discussed below in connection with FIG. 8, in a situation where there is a low level or degree of lock contention on a leaf page 602 that had previously experienced lock contention, then the index key 503 that was previously attempted to be stored by transaction 601 on such leaf page 602 is removed from the index distribution queue buffer 506 and stored in the appropriate leaf page 602 using the index leaf router map 604.

[0124] FIG. 8 is a flowchart of a method 800 for asynchronously inserting an index key 503 into an appropriate leaf page 602 that previously experienced a lock contention where a transaction 601 had previously attempted to store such index key 503 in such leaf page 602, in accordance with an embodiment of the present disclosure.

[0125] Referring to FIG. 8 in conjunction with FIGS. 1-3 and 5-6, in operation 801, the monitoring engine 201 of the relational database management system 102 measures the extent of lock contention for a leaf page 602 (e.g., leaf page 602A) of an index that was previously identified as experiencing lock contention.

[0126] In operation 802, the monitoring engine 201 of the relational database management system 102 determines whether the level of lock contention on such leaf page 602 that previously experienced lock contention has fallen below a threshold level, which may be user-specified. If such a situation occurs, the leaf page 602 may be said to be experiencing a low level of lock contention and therefore is now safe to store additional index keys 503. As used herein, a "low level" of lock contention refers to a leaf page that is deemed to no longer be experiencing lock contention.

[0127] As discussed above, in one embodiment, the monitoring engine 201 is configured to detect the level of lock contention on the leaf pages 602 of the index, e.g., to determine whether it is below a threshold level, which may be user-specified. In one embodiment, the degree or level of lock contention on the leaf pages of the index is determined by the monitoring engine 201 based on the number of transactions attempting to store index keys 503 on the leaf pages 602, as well as based on the page free size information 605. As used herein, "page free size information" refers to the amount of memory space available on the leaf pages 602 for storing index keys 503. In one embodiment, each leaf page 602 of an index (e.g., an SQL index) is assigned a particular size (e.g., 3 KB) by an expert or the like. In one embodiment, the monitoring engine 201 is configured to track the amount of memory used by the storage of index keys 503, and thus can determine the amount of memory space remaining for storing additional index keys 503. Examples of software tools that may be utilized by the monitoring engine 201 to track memory usage of leaf pages 602 of indexes (e.g., SQL indexes) include, but are not limited to, SQLShack, ApexSQL by Quest®, and the like.

[0128] In one embodiment, a degree or level of lock contention in a leaf page 602 may be determined based on such memory usage of the leaf page 602 of an index and the number of index keys 503 to be written to the leaf page 602. For example, if the number of index keys 503 to be written to the leaf page 602 requires memory space that is more than 50% of the remaining available memory space in the leaf page 602, the leaf page 602 may be said to be experiencing lock contention. On the other hand, if the number of index keys 503 to be written to the leaf page 602 requires memory space that is less than 25% of the remaining available memory space in the leaf page 602, the leaf page 602 may be said to be experiencing a low level of lock contention.

[0129] If the level of lock contention on leaf pages 602 that were previously experiencing lock contention has not fallen below the threshold level, the detector engine 205 continues to measure the degree of lock contention on leaf pages 602 of the index previously identified in operation 801 as experiencing lock contention.

[0130] However, if the level of lock contention on a leaf page 602 that was previously experiencing lock contention has fallen below a threshold level, then in operation 803, the routing engine 203 of the relational database management system 102 removes from the index distribution queue buffer 506 the appropriate index key 503 to be asynchronously inserted into the leaf page 602 that is currently experiencing a low level of lock contention based on the index leaf router map 604, as shown in FIG. 6.

[0131] 6, for example, if it is determined that leaf page 602A ("leaf #5") is currently experiencing a low level of lock contention, routing engine 203 identifies which index keys 503 are to be removed from index distribution queue buffer 506 and inserted into leaf page 602A based on identifying queue locations storing such index keys 503 that are mapped to such leaf page 602A in index leaf router map 604. For example, identifiers of storage locations of index keys 503 (queue positions Q11, Q13, Q22, Q24, Q16_1, and Q16_4) are mapped to leaf page 602A. As a result, routing engine 203 removes such index keys 503 from queues 507 of index distribution queue buffer 506 that are to be stored in leaf page 602A, such as in a batch.

[0132] In one embodiment, the routing engine 203 obtains from the index distribution queue buffer 506 only the number of index keys 503 that the leaf page 602 (e.g., leaf page 602A) can currently store without reaching a "lock contention" state (i.e., high level of lock contention as opposed to low level of lock contention). In one embodiment, the lock contention state of the leaf page 602 (e.g., leaf page 602A) is continuously monitored by the monitoring engine 201, and as a result, the number of index keys 503 stored in the index distribution queue buffer 506 as opposed to being stored in the leaf page 602 (e.g., leaf page 602A), or the number of index keys 503 removed from the index distribution queue buffer 506 and inserted into the leaf page 602 (e.g., leaf page 602A) by the routing engine 203 is performed dynamically.

[0133] Additionally, as discussed below in connection with FIG. 9, in one embodiment, an index key 503 may be removed from the index distribution queue buffer 506 and synchronously inserted into a leaf page 602 (e.g., leaf page 602A) in response to detecting a split of that leaf page 602 (e.g., leaf page 602A), the triggering of a system checkpoint for that leaf page 602 (e.g., leaf page 602A), or the receipt of a SELECT, UPDATE, or DELETE statement (e.g., a SELECT SQL statement, an UPDATE SQL statement, a DELETE SQL statement) involving such leaf page 602 (e.g., leaf page 602A).

[0134] FIG. 9 is a flowchart of a method 900 for synchronously inserting an index key 503 into a leaf page 602 (e.g., leaf page 602A) in response to detecting an index split of a leaf page 602 (e.g., leaf page 602A), a system checkpoint involving a leaf page 602 (e.g., leaf page 602A), or receipt of a SELECT statement, an UPDATE statement, or a DELETE statement involving a leaf page 602 (e.g., leaf page 602A), in accordance with an embodiment of the present disclosure.

[0135] Referring to FIG. 9 in conjunction with FIGS. 1-3 and 5-6, in operation 901, the detector engine 205 of the relational database management system 102 determines whether a leaf page split, the triggering of a system checkpoint for the leaf page 602, or the receipt of a SELECT statement, UPDATE statement, or DELETE statement involving the leaf page 602 has been detected.

[0136] As discussed above, in one embodiment, the detector engine 205 is configured to detect leaf page splits, the triggering of a system checkpoint for the leaf page 602, and the receipt of a SELECT, UPDATE, or DELETE statement involving the leaf page 602.

[0137] As discussed above, as used herein, a "split" of a leaf page 602 refers to a situation when there is not enough memory space to add new data (e.g., new rows) that is required to be in a leaf page, and as a result, the leaf page 602 must split. When a split occurs, the leaf page 602 may be split into two pages, with each leaf page 602 having approximately half of the rows of the original leaf page 602. As a result, the detector engine 205 detects a leaf page split upon the creation of a new leaf page 602 to store half of the data stored in another leaf page 602.

[0138] Furthermore, as discussed above, as used herein, a "system checkpoint" for a leaf page 602 refers to a test operation that validates data, such as index keys 503, obtained from a leaf page 602 by comparing the data to a baseline copy. In one embodiment, the detector engine 205 detects such a system checkpoint based on detecting the issuance of a checkpoint by the database engine 206 (e.g., a SQL Server database engine) of the relational database management system 102.

[0139] Additionally, as discussed above, SELECT statements, such as SQL SELECT statements, are used to select data from the database 104. UPDATE statements, such as SQL UPDATE statements, are used to modify existing records in tables of the database 104. DELETE statements, such as SQL DELETE statements, are used to delete existing records in tables of the database 104. In one embodiment, the detector engine 205 is configured to detect receipt of such statements based on identifying such statements in a query received by the relational database management system 102 from the computing device 101. In one embodiment, the detector engine 205 utilizes natural language processing to identify such statements in a query, and such terms are stored in a data structure stored by the expert. In one embodiment, such data structure is stored in a storage device (e.g., memory 305, disk unit 308) of the relational database management system 102.

[0140] If a leaf page split, the triggering of a system checkpoint for the leaf page 602, or the receipt of a SELECT, UPDATE, or DELETE statement involving the leaf page 602 is not detected, the detector engine 205 continues in operation 901 to determine whether a leaf page split, the triggering of a system checkpoint for the leaf page 602, or the receipt of a SELECT, UPDATE, or DELETE statement involving the leaf page 602 is detected.

[0141] However, as shown in FIG. 6, if a leaf page split, the triggering of a system checkpoint for the leaf page 602, or the receipt of a SELECT, UPDATE, or DELETE statement involving the leaf page 602 is detected, in operation 902, the routing engine 203 of the relational database management system 102 removes from the index distribution queue buffer 506 the index key 503 that is to be synchronously inserted into the leaf page 602 (e.g., leaf page 602A) in response to detecting a leaf page split for such leaf page 602 (e.g., leaf page 602A), the triggering of a system checkpoint involving such leaf page 602 (e.g., leaf page 602A), or the receipt of a SELECT, UPDATE, or DELETE statement involving such leaf page 602 (e.g., leaf page 602A).

[0142] 6, for example, when a leaf page split of leaf page 602A, the triggering of a system checkpoint involving leaf page 602A, or the receipt of a SELECT, UPDATE, or DELETE statement involving leaf page 602A is detected, routing engine 203 identifies which index keys 503 are to be removed from index distribution queue buffer 506 and inserted into leaf page 602A based on identifying the queue locations storing such index keys 503 that are mapped to such leaf page 602A in index leaf router map 604. For example, identifiers of the storage locations (queue positions Q11, Q13, Q22, Q24, Q16_1, and Q16_4) of index keys 503 that are mapped to leaf page 602A are stored in index leaf router map 604. As a result, routing engine 203 removes such index keys from queues 507 of index distribution queue buffer 506 that are to be stored in leaf page 602A, such as in a batch.

[0143] In one embodiment, the routing engine 203 obtains from the index distribution queue buffer 506 only the number of index keys 503 that the leaf page 602 (e.g., leaf page 602A) can currently store without reaching a "lock contention" state (i.e., high level of lock contention as opposed to low level of lock contention). In one embodiment, the lock contention state of the leaf page 602 (e.g., leaf page 602A) is continuously monitored by the monitoring engine 201, and as a result, the number of index keys 503 stored in the index distribution queue buffer 506 as opposed to being stored in the leaf page 602 (e.g., leaf page 602A), or the number of index keys 503 removed from the index distribution queue buffer 506 and inserted into the leaf page 602 (e.g., leaf page 602A) by the routing engine 203 is performed dynamically.

[0144] 10, in one embodiment, the relational database management system 102 may asynchronously pre-allocate multiple leaf pages 602 to reduce the possibility of future lock contention after an index split if a sequential insertion pattern is detected. As used herein, "pre-allocation" ensures that memory space in such leaf pages 602 is available when the routing engine 203 needs to store an index key 503 in such leaf pages 602.

[0145] FIG. 10 is a flowchart of a method 1000 for pre-allocating leaf pages 602 during an index split if a potential future lock conflict is detected, according to an embodiment of the present disclosure.

[0146] Referring to FIG. 10 in conjunction with FIGS. 1-3 and 5-6, in operation 1001, the detector engine 205 of the relational database management system 102 determines whether a sequential pattern of index keys 503 has been detected as being inserted into leaf pages 602 during index splitting.

[0147] If a sequential pattern of index keys 503 is not detected as being inserted into leaf pages 602 during index splitting, the detector engine 205 continues in operation 1001 to determine whether a sequential pattern of index keys 503 is detected as being inserted into leaf pages 602 during index splitting.

[0148] However, if a sequential pattern of index keys 503 is detected as being inserted into leaf pages 602 during the index split, then in operation 1002, the detector engine 205 of the relational database management system 102 asynchronously pre-allocates multiple leaf pages 602 of the index to reduce possible lock contention scenarios.

[0149] As discussed above, when an index split occurs, a leaf page 602 may be split into two pages with each leaf page 602 having roughly half of the rows of the original leaf page. In one embodiment, if a sequential pattern of index keys 503 (continuous movement pattern) is entered into such leaf pages 602, the detector engine 205 asynchronously pre-allocates multiple leaf pages 602 of the index to reduce possible lock contention scenarios. Since the sequential pattern of index keys 503 may continue within such leaf pages 602, it can be said that lock contention is more likely to occur in such a situation. In one embodiment, such a sequential movement pattern is detected by the detector engine 205 by using high / low key values ​​from previous leaf pages 602 to predict key values ​​as non-leaf key values ​​for those new pre-allocated leaf pages 602. An illustration of such pre-allocation according to an embodiment of the present disclosure is shown in FIG. 11.

[0150] FIG. 11 illustrates pre-allocating leaf pages during index splitting according to an embodiment of the present disclosure.

[0151] 11, leaf pages 602E-602G (identified in FIG. 11 as "Leaf #8," "Leaf #9," and "Leaf #10," respectively) are asynchronously pre-allocated to reduce possible lock contention scenarios resulting from detection of sequential patterns (continuous movement patterns) of index keys 503 entered into leaf pages 602 (e.g., leaf pages 602A-602D) during index splitting. As a result of such pre-allocation, memory space in leaf pages 602E-602G is available when routing engine 203 needs to store index keys 503 in such leaf pages 602 from the detected sequential pattern of index keys 503.

[0152] Further, in one embodiment, the mapping engine 204 pre-allocates a mapping of such pre-allocated leaf pages 602 in an index leaf router map 604, as shown in FIG. 11. For example, the index leaf router map 604 stores a mapping of index keys 503 stored in leaf pages 602A, 602B, and 602C (identified in FIG. 11 as “Leaf #5”, “Leaf #6”, and “Leaf #7”, respectively). Further, the index leaf router map 604 stores page free size information 605A-605C for leaf pages 602A-602C, respectively. In addition, for pre-allocated leaf pages 602E-602G, the mapping engine 204 pre-allocates a mapping of such pre-allocated leaf pages 602 in the index leaf router map 604, which also includes storage of page free size information 605D-605F for such pre-allocated leaf pages 602E-602G, respectively.

[0153] As a result of the above, embodiments of the present disclosure provide a means for efficiently handling lock contention for leaf pages of an index, such as an SQL index, by utilizing a buffer (referred to herein as an "index distribution queue buffer") for storing such index keys in a queue of buffers, as opposed to storing the index keys in the leaf pages experiencing lock contention. When such leaf pages no longer experience such lock contention, the appropriate index keys are then removed from the index distribution queue buffer and stored in the appropriate leaf pages based on a data structure (referred to herein as an "index leaf router map") that maps index keys stored in the index distribution queue buffer to appropriate leaf pages of the index.

[0154] Furthermore, the principles of the present disclosure improve upon the art or field of technology related to relational database management systems. As discussed above, an SQL query, such as an SQL INSERT INTO statement, may be received and processed by a relational database management system (e.g., an SQL server). Such a query (e.g., an SQL INSERT INTO statement) may be used to add a new row of data to a table in a database. When such a scenario occurs, the associated index defined on this table needs to be updated. An index is an on-disk structure associated with a table or view that speeds up retrieval of rows from the table or view. An index typically includes a key constructed from one or more columns in the table or view. These keys are stored in a structure (a B-tree) that allows the relational database management system to quickly and efficiently find the row or rows associated with the key value. As a result, when a new row of data is added to a table in a database, the index needs to be updated to include the key value associated with such row of data. Storing such a key value in an index is referred to herein as a "transaction." A B-tree index creates a multi-level tree structure that divides the database into fixed-size blocks or pages. This tree at each level can be used to link the pages together via their address locations, allowing one page (known as a node or interior page) to reference another page at the lowest level, which is a leaf page. One page is usually the beginning or "root" of the tree, where a search for a particular key begins and follows a path that ends at a leaf. That is, the leaf pages of an index are the lowest level of the index where all the keys for that index appear in sorted order. Most pages in such a structure are leaf pages that ultimately reference particular table rows.Sometimes, multiple different transactions attempt to insert key values ​​into the leaf pages of an index (e.g., an SQL index) simultaneously, resulting in "lock contention" that adversely affects performance. "Lock contention" occurs whenever one process (transaction) attempts to acquire a "lock" held by another process (transaction). In an attempt to address lock contention, such transactions may be handled in a randomized manner. However, processing of queries, such as SQL queries, associated with such transactions will suffer performance. In yet another attempt to address lock contention, the minimum page size of the leaf pages of an index may be increased. However, lock contention will only be reduced slightly. Furthermore, as a result of increasing the minimum page size of the leaf pages of an index, more database input / output operations will be required during index access. As a result, currently there is no means to effectively handle lock contention on the leaf pages of an index (e.g., an SQL index).

[0155] An embodiment of the present disclosure improves upon such techniques by monitoring leaf pages of an index (e.g., an SQL index) for lock contention during an index key insert operation by a transaction. As used herein, a "lock contention" refers to any time when one process (transaction) attempts to obtain a "lock" on a leaf page of an index held by another process (transaction). As used herein, an "index" refers to an on-disk structure associated with a table or view that speeds up retrieval of rows from the table or view. In one embodiment, such an index stores a "key" or "index key" constructed from one or more columns in the table or view. As used herein, an "index key" refers to a key of an index (e.g., an SQL index) that allows a relational database management system to quickly and efficiently find a row or rows associated with a key value. Storing such a key value in an index is referred to herein as a "transaction." Additionally, a "leaf page" of an index is the lowest level of the index where all keys for that index are displayed in sorted order. Upon detecting a lock contention for a leaf page, the next index key to be entered into such leaf page is routed to a queue in a buffer (referred to herein as the "index distribution queue buffer"). The index key stored in the queue of the index distribution queue buffer is then mapped to the particular leaf page experiencing the lock contention where the transaction originally attempted to store such index key. In one embodiment, such mapping is stored in a data structure referred to herein as the "index leaf router map," which stores the mapping of index keys stored in the queue of the index distribution queue buffer to leaf pages of the index.When such leaf pages no longer experience such lock contention, the appropriate index keys are then removed from the index distribution queue buffer and stored in the appropriate leaf pages based on the mapping in the index leaf router map. In this manner, lock contention for leaf pages of indexes, such as SQL indexes, is handled efficiently. Further, in this manner, an improvement is made in the art involving relational database management systems.

[0156] The technical solutions provided by the present disclosure cannot be implemented in the human mind or by a human using pen and paper, i.e., the technical solutions provided by the present disclosure cannot be realized in the human mind or by a human using pen and paper, in any reasonable amount of time, and with any reasonable expectation of accuracy, without the use of a computer.

[0157] The description of various embodiments of the present disclosure is presented for illustrative purposes, but is not intended to be exhaustive or limited to the disclosed embodiments. Many modifications and variations that do not depart from the scope and spirit of the described embodiments will be apparent to those skilled in the art. The terminology used in this specification has been selected to best explain the principles of the embodiments, practical applications, or technical improvements to the technology found in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.

Claims

1. 1. A computer-implemented method for handling lock contention on an index, comprising: monitoring leaf pages of the index for lock contention during an index key insert operation; in response to detecting the lock contention for the leaf page of the index, routing a first index key to a queue of a buffer, where the first index key corresponds to an index key of a transaction that is to be inserted into the leaf page of the index; and storing in a data structure a mapping of the first index key stored in the queue of the buffer to the leaf page experiencing the lock conflict, wherein the data structure stores a mapping of the index key stored in the queue of the buffer to the leaf pages of the index. A computer-implemented method comprising:

2. 2. The computer-implemented method of claim 1, wherein the lock conflict is detected based on a page or row level lock wait queue length or based on a latch wait queue length.

3. 3. The computer-implemented method of claim 1, further comprising: routing a second index key that follows the first index key to the queue of the buffer, where the index keys stored in the queue of the buffer are synchronized via compare-and-swap.

4. 10. The computer-implemented method of claim 9, wherein the data structure includes an identifier of a storage location of the first index key in the queue of the buffer along with an identifier of the leaf page experiencing the lock contention, and wherein the identifiers of storage locations of index keys in the data structure are synchronized via compare-and-swap.

5. 4. The computer-implemented method of any preceding claim, further comprising: in response to detecting a level of lock contention on the leaf page being below a threshold level, removing from the buffer index keys that are to be asynchronously inserted into a leaf page based on the data structure.

6. 5. The computer-implemented method of claim 1, further comprising removing from the buffer index keys that are to be synchronously inserted into a leaf page based on the data structure in response to detecting one of the following selected from the group consisting of: splitting the leaf page; triggering a system checkpoint for the leaf page; and a SELECT, UPDATE, or DELETE statement involving the leaf page.

7. creating a new queue within the buffer in response to the queue reaching a threshold percentage of a maximum queue length; and Routing newly incoming index keys to the new queue.

13. The computer-implemented method of any preceding claim, further comprising:

8. 1. A computer program product for handling lock contention for an index, comprising: one or more computer readable storage media having program code embodied thereon, the program code comprising: monitoring leaf pages of said index for lock contention during an index key insert operation; in response to detecting the lock contention for the leaf page of the index, routing a first index key to a queue of a buffer, where the first index key corresponds to an index key of a transaction that is to be inserted into the leaf page of the index; and storing in a data structure a mapping of the first index key stored in the queue of the buffer to the leaf page experiencing the lock conflict, wherein the data structure stores a mapping of the index key stored in the queue of the buffer to the leaf pages of the index.

4. A computer program product having programming instructions for:

9. 9. The computer program product of claim 8, wherein the lock conflict is detected based on a page or row level lock wait queue length or based on a latch wait queue length.

10. The program code: routing a second index key subsequent to the first index key to the queue of the buffer, where the index keys stored in the queue of the buffer are synchronized via a compare-and-swap.

10. A computer program product according to claim 8 or 9, further comprising the programming instructions for:

11. 11. The computer program product of claim 8, wherein the data structure includes an identifier of a storage location of the first index key in the queue of the buffer along with an identifier of the leaf page experiencing the lock conflict, and the identifiers of the storage locations of index keys in the data structure are synchronized via compare-and-swap.

12. The program code: In response to detecting that a level of lock contention on the leaf page is below a threshold level, removing from the buffer index keys that are to be asynchronously inserted into the leaf page based on the data structure.

12. A computer program product according to any of claims 8 to 11, further comprising the programming instructions for:

13. The program code: removing from said buffer an index key that is to be synchronously inserted into a leaf page based on said data structure in response to detecting one selected from the group consisting of: splitting said leaf page; triggering a system checkpoint for said leaf page; and a SELECT, UPDATE, or DELETE statement involving said leaf page.

13. A computer program product according to any of claims 8 to 12, further comprising the programming instructions for:

14. The program code: creating a new queue within the buffer in response to the queue reaching a threshold percentage of a maximum queue length; and Routing newly incoming index keys to the new queue. A computer program product according to any of claims 8 to 13, further comprising the programming instructions for:

15. memory for storing a computer program for handling lock contention for an index; and A processor coupled to the memory, the processor comprising: monitoring leaf pages of said index for lock contention during an index key insert operation; in response to detecting the lock contention for the leaf page of the index, routing a first index key to a queue of a buffer, where the first index key corresponds to an index key of a transaction that is to be inserted into the leaf page of the index; and storing in a data structure a mapping of the first index key stored in the queue of the buffer to the leaf page experiencing the lock conflict, wherein the data structure stores a mapping of the index key stored in the queue of the buffer to the leaf pages of the index. configured to execute program instructions of the computer program having A system comprising:

16. 16. The system of claim 15, wherein the lock conflict is detected based on a page or row level lock wait queue length or based on a latch wait queue length.

17. The program instructions of the computer program: routing a second index key subsequent to the first index key to the queue of the buffer, where the index keys stored in the queue of the buffer are synchronized via a compare-and-swap.

17. The system of claim 15 or 16, further comprising:

18. 18. The system of claim 15, wherein the data structure includes an identifier of a storage location of the first index key in the queue of the buffer along with an identifier of the leaf page experiencing the lock conflict, and the identifiers of the storage locations of index keys in the data structure are synchronized via compare-and-swap.

19. The program instructions of the computer program: In response to detecting that a level of lock contention on the leaf page is below a threshold level, removing from the buffer index keys that are to be asynchronously inserted into the leaf page based on the data structure. The system according to any one of claims 15 to 18, further comprising:

20. The program instructions of the computer program: removing from said buffer an index key that is to be synchronously inserted into a leaf page based on said data structure in response to detecting one selected from the group consisting of: splitting said leaf page; triggering a system checkpoint for said leaf page; and a SELECT, UPDATE, or DELETE statement involving said leaf page. The system according to any one of claims 15 to 19, further comprising:

21. A computer program comprising program code means adapted to perform the computer implemented method of any of claims 1 to 7, when said computer program is run on a computer.

Citation Information

Patent Citations

  • Method and device for managing data and recording medium with data management program stored therein

    JP2001282599A

  • Database management system and database management program

    JP2004341926A

  • B+ tree index processing method, b+ tree index processing apparatus, and program

    JP2013242677A

  • Index tree search method and computer

    JP2015170239A

  • Dynamic splitting of contentious index data pages

    US11080253B1