Claims
- 1. A method of accessing index nodes of an index structure for searching data in a database in an environment where the index structure residing in main memory consists of index nodes, each index node having node contents, a version number indicating the updated status of the node contents, and a latch governing concurrent access to each node, the method comprising the step of:
performing a latch-free read operation on a node, further comprising the steps of:
copying the version number of the node into a register; reading the contents of the node after copying the version number; checking the latch of the node after reading the contents, and if the latch has been locked on the node, going back to the step of copying the version number of the node for retrial; and checking the version number of the node after checking the latch, and if the current version number is different from the copied version number, going back to the step of copying the version number of the node for retrial.
- 2. The method of claim 1, wherein the node contents are updated by performing an update operation on a node that comprises the steps of:
locking the latch of the node before updating; updating the contents of the node; incrementing the version number of the node after updating; and releasing the latch by resetting the latch.
- 3. The method of claim 2, wherein the latch and the version number are contained in a single word containing the latch and the version number.
- 4. The method of claim 3, wherein the least significant bit (LSB) of the single word is used for the latch and the other bits are used for the version number.
- 5. The method of claim 4, wherein the step of copying the version number of the node is executed by a turn-off-LSB function that returns the value of the single word with its LSB turned off as a value, and the step of checking the latch and the step of checking the version number are executed by comparing the value with the current value of the single word.
- 6. The method of claim 4, wherein the step of locking the latch of the node comprises the steps of:
executing a turn-off-LSB function that returns the value of the single word with its LSB turned off as a first value; executing a turn-on-LSB function that returns the value of the single word with its LSB turned on as a second value; executing a compare-and-swap instruction that compares the first value with the current value of the single word, and if the two are the same, replaces the single word with the second value; and going to the step of executing a turn-off-LSB instruction for repetition f the two are not the same.
- 7. The method of claim 4, wherein the step of incrementing the version number and the step of releasing the latch are executed by an instruction that increments the value of the single word by 1.
- 8. The method of claim 1, further comprising the step of inserting a delay before going back to the step of copying the version number when the latch has been locked on the node.
- 9. The method of claim 1, further comprising the step of inserting a delay before going back to the step of copying the version number if the current version number is different from the copied version number.
- 10. The method of claim 1, further comprising the step of limiting the number of retrials to a predetermined number.
- 11. The method of claim 10, further comprising the step of acquiring a shared latch before reading a node when the number of retrials exceeds the predetermined number.
- 12. The method of claim 1, wherein said database resides in main memory.
- 13. The method of claim 1, wherein said database resides in disk.
- 14. The method of claim 1, wherein said database is accessed for transaction processing.
- 15. The method of claim 1, wherein the environment includes multiple processors independently accessing the index structure.
- 16. The method of claim 1, wherein the environment includes a uni-processor running multiple threads, each thread independently accessing the index structure.
- 17. The method of claim 1, wherein said database is a relational DBMS.
- 18. The method of claim 1, wherein said index structure is a tree and the node contents further include a high key indicating an upper bound of key values in the node and link pointers to other nodes at the same level.
- 19. The method of claim 1, wherein a part of said index tree resides in one or more caches.
- 20. The method of claim 1, wherein said index structure is a B+-tree.
- 21. The method of claim 1, wherein said index structure is a CSB+-tree.
- 22. The method of claim 1, wherein said index structure is a B-tree.
- 23. The method of claim 1, wherein said index structure is a B*-tree.
- 24. The method of claim 1, wherein the index structure is a T-tree.
- 25. The method of claim 1, wherein the index structure is an R-tree.
- 26. The method of claim 1, wherein the index structure is a CR-tree.
- 27. The method of claim 1, wherein the index structure is a GiST.
- 28. A method of traversing an index tree consisting of nodes for searching data in a database of a database management system having main memory and cache, in order to find a leaf node corresponding to a search key while reducing coherence cache misses through latch-free read operations in the database management system, where each node has contents, a version number indicating the updated status of the node contents, a latch governing concurrent access to each node, wherein the node contents further includes one or more keys, a high key denoting the upper bound of the keys, a link pointer pointing to the right sibling of the node at the same level, and one or more pointers to data items in the database in the case of a leaf node and to child nodes in the case of a non-leaf node, the method comprising the steps of:
starting from the root node; following the link pointer if the search key is greater than the high key of the node; and following the pointer to a child node if the key is not greater than the high key of the node; and repeating said steps of following the link pointer and the following the pointer until a leaf node corresponding to the search key is found.
- 29. The method of claim 28, wherein the node contents of a node are accessed by performing a latch-free read operation of the node to read the content of the node for further traversing without interfering with any update operation on the node, comprising the steps of:
copying the version number of the node into a register; reading the contents of the node; checking the latch of the node and if the latch has been locked on the node, going back to the step of copying the version number of the node for retrial; and checking the version number of the node and if the current version number is different from the copied version number, going back to the step of copying the version number of the node for retrial.
- 30. The method of claim 28, wherein a new node is added to an old node by performing a split operation comprising the steps of:
creating a new node; moving from the old node to the new node one or more of the keys, one or more of the pointers, the link pointer pointing to the right sibling; calculating the high key for the new node; calculating the new high key for the old node; and changing the link pointer of the old node such that it points to the new node.
- 31. The method of claim 28, wherein a node is deleted by deleting a leaf node when its node contents no longer have any pointer to data item in the database.
- 32. The method of claim 28, wherein a node is deleted by deleting a non-leaf node when its node contents no longer have any pointer to a child node.
- 33. The method of claim 28, wherein said database resides in main memory.
- 34. The method of claim 28, wherein said database resides in disk.
- 35. The method of claim 28, wherein said database is accessed for transaction processing.
- 36. The method of claim 28, wherein said database management system includes multiple processors independently accessing the index structure.
- 37. The method of claim 28, wherein said database management system includes a uni-processor running multiple threads, each thread independently accessing the index structure.
- 38. The method of claim 28, wherein said index tree is a B+-tree.
- 39. The method of claim 28, wherein said index tree is a CSB+-tree.
- 40. The method of claim 28, wherein said index tree is a B-tree.
- 41. The method of claim 28, wherein said index tree is a B*-tree.
- 42. An index tree for searching data in a database, consisting of leaf nodes and non-leaf nodes, wherein each node comprises:
node contents; a version number indicating the updated status of the node contents; and a latch governing concurrent access to each node; wherein the node contents further comprises:
one or more keys; a high key indicating the upper bound of the keys in the node; a link pointers pointing to the right sibling of the node at the same level; and one or more pointers to data items in the database in the case of a leaf node and to child nodes in the case of non-leaf nodes.
- 43. The method of claim 42, wherein the index structure constitutes a B+-tree.
- 44. The method of claim 42, wherein the index structure constitutes a B+-tree variant.
- 45. A system for managing a database in a multiprocessing environment, comprising:
main memory for storing an index structure having index nodes for accessing the database wherein each index node has node contents for accessing each record of the database, a version number for indicating the updated version, and a latch for governing concurrent access to the node; and one or more caches for storing frequently accessed index nodes;
- 46. The system of claim 45, further comprising:
means for performing a consistent update operation on a node; and means for performing a latch-free read operation on a node.
- 47. The system of claim 45, further including a single word for containing the version number and the latch for each node.
- 48. The system of claim 45, wherein the node contents include pointers to other nodes and key values.
- 49. The system of claim 45, wherein the database resides in main memory
- 50. The system of claim 45, wherein the database resides in disk.
- 51. The system of claim 45, wherein the database is accessed for transaction processing.
- 52. The system of claim 45, wherein the multiprocessing environment includes multiple processors independently accessing the index structure.
- 53. The system of claim 45, wherein the multiprocessing environment includes a uni-processor executing multiple threads, each tread independently accessing the index structure.
- 54. The system of claim 45, wherein said index structure is a B+-tree.
- 55. The system of claim 45, wherein said index structure is a CSB+-tree.
- 56. The system of claim 45, wherein said index structure is a B-tree.
- 57. The system of claim 45, wherein said index structure is a B*-tree.
- 58. The system of claim 45, wherein the index structure is a T-tree.
- 59. The system of claim 45, wherein the index structure is an R-tree.
- 60. The system of claim 45, wherein the index structure is a CR-tree.
- 61. The system of claim 45, wherein the index structure is a GiST.
- 62. A computer program product for controlling a system having main memory storing an index tree having index nodes for accessing a database, each index node having node contents, a version number indicating the updated status of the node contents, and a latch governing concurrent access to each node, and one or more caches for storing frequently assessed index nodes, wherein the program when executed in a computer performs latch-free reading of a node of the index tree comprising the steps of:
copying the version number of the node into a register; reading the contents of the node; checking the latch of the node and if the latch has been locked on the node, going back to the step of copying the version number of the node for retrial; and checking the version number of the node and if the current version number is different from the copied version number, going back to the step of copying the version number of the node for retrial.
- 63. The computer program product of claim 62, where the program when executed further performs a consistent update operation comprising the steps of:
setting the latch of a node; updating the node contents of the node; incrementing the version number of the node; and releasing the latch by resetting the latch.
- 64. The program product of claim 62, wherein said index tree is a B+-tree.
- 65. The program product of claim 62, wherein said index tree is a B+-tree variant.
- 66. The program product of claim 62, wherein the program product is stored in one or more CDs.
- 67. The program product of claim 62, wherein the program product is stored in disk.
RELATED APPLICATION
[0001] This application claims the benefit of co-pending U.S. Provisional Application Ser. No. 60/296,870, filed Jun. 8, 2001, entitled “Cache-Conscious Concurrency Control Scheme for Index Structures in Main-Memory Database Systems.”
Provisional Applications (1)
|
Number |
Date |
Country |
|
60296870 |
Jun 2001 |
US |