Skip to content

Commit 26f5161

Browse files
committed
Update Chapter4_2.md
1 parent 96f8ea3 commit 26f5161

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

Chapter4_2.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ A linked list (or simply "list") is a linear collection of data elements, called
9494

9595
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.
9696

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.
9898

9999
```c++
100100
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
103103
Recs *recs;
104104
```
105105

106-
To address this problem, some databases adopt centralized storage for undo history versions, which significantly reduces the cost of garbage collection.
107-
108106
### 4.2.3 Queue
109107

110108
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>
136134
class mem_root_deque {
137135
```
138136
139-
140-
141137
### 4.2.4 Heap
142138
143139
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
301297
302298
Regarding query efficiency, the hybrid data structure offers substantial improvements. For instance, to check if transaction ID=24 is in the active transaction list:
303299
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).
306302
307303
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.
308304

0 commit comments

Comments
 (0)