You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Chapter4_2.md
+3-7Lines changed: 3 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -94,7 +94,7 @@ A linked list (or simply "list") is a linear collection of data elements, called
94
94
95
95
MySQL commonly uses the list from the standard library, which typically implements a doubly linked list to facilitate easy insertion and deletion, though it often suffers from poor query performance. In mainstream NUMA architectures, linked lists are generally inefficient for querying due to non-contiguous memory access patterns. Consequently, linked lists are best suited as auxiliary data structures or for scenarios involving smaller data volumes.
96
96
97
-
Below is the list data structure used by *undo*. As the *undo* list grows longer, MVCC efficiency is significantly reduced.
97
+
In large-scale projects, to avoid the unpredictability of memory allocation in linked lists, a memory pool can be used for better management. Below is the list data structure used by *undo*. As the *undo* list grows longer, MVCC efficiency is significantly reduced.
98
98
99
99
```c++
100
100
using Recs = std::list<rec_t, mem_heap_allocator<rec_t>>;
@@ -103,8 +103,6 @@ Below is the list data structure used by *undo*. As the *undo* list grows longer
103
103
Recs *recs;
104
104
```
105
105
106
-
To address this problem, some databases adopt centralized storage for undo history versions, which significantly reduces the cost of garbage collection.
107
-
108
106
### 4.2.3 Queue
109
107
110
108
In computer science, a queue is a collection of entities organized in a sequence, where entities can be added at one end and removed from the other. The operation of adding an element to the rear is called enqueue, while removing an element from the front is called dequeue. This makes a queue a first-in-first-out (FIFO) data structure, meaning the first element added will be the first one removed. In other words, elements are processed in the order they are added.
@@ -136,8 +134,6 @@ template <class Element_type>
136
134
classmem_root_deque {
137
135
```
138
136
139
-
140
-
141
137
### 4.2.4 Heap
142
138
143
139
In computer science, a heap is a tree-based data structure that maintains the heap property and is typically implemented using an array [45]. It serves as an efficient implementation of the abstract data type known as a priority queue. Priority queues are often referred to as "heaps" regardless of their underlying implementation. In a heap, the element with the highest (or lowest) priority is always at the root. However, unlike a sorted structure, a heap is partially ordered.
@@ -301,8 +297,8 @@ The active transaction list length is 17, with each transaction ID requiring 8 b
301
297
302
298
Regarding query efficiency, the hybrid data structure offers substantial improvements. For instance, to check if transaction ID=24 is in the active transaction list:
303
299
304
-
- In the original approach, a binary search is needed, with a time complexity of O(log n).
305
-
- With the hybrid structure, using the minimum short transaction ID as a baseline allows direct querying through the static data, achieving a time complexity of O(1).
300
+
- In the original approach, a binary search is needed, with a time complexity of O(log n).
301
+
- With the hybrid structure, using the minimum short transaction ID as a baseline allows direct querying through the static data, achieving a time complexity of O(1).
306
302
307
303
In NUMA environments, as shown in the figure below, it can be seen that simply changing the data structure can significantly increase the throughput of TPC-C under high-concurrency conditions, greatly alleviating scalability problems related to MVCC ReadView.
0 commit comments