Consultation on TiDB Data Writing Mechanism

This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: tidb数据写入机制请教

| username: magongyong

[Test Environment for TiDB] Testing
[TiDB Version] 5.4.3
[Reproduction Path] What operations were performed when the issue occurred
[Encountered Issue: Issue Phenomenon and Impact]

As shown in the above image, I understand that phase one involves unordered writes to the memtable, and phase two involves sorting and writing to the disk. Is this correct?
In the video, it is mentioned that phase two involves direct writes to the disk. How are the key-values sorted then?

[Resource Configuration]
[Attachments: Screenshots/Logs/Monitoring]

| username: xfworld | Original post link

You haven’t finished reading it, right?

immutable → sst

There are still many details at this stage, such as asynchronous flushing, flow control management, etc.
Then during the write process, there are different levels. Among them, sst level0 and immutable are completely consistent and unordered.

However, when level 0 → level 1 compression occurs, sorting is performed, which is the compacting operation.

| username: TiDBer_pkQ5q1l0 | Original post link

L0 directly restores the immutable to the disk, and L1 and later levels perform sorting and compression.

| username: Jiawei | Original post link

The first stage of writing to the memtable is sequential, but the file is unordered.
For sorting, it is recommended to look at the mini compaction and major compaction of the LSM tree, which will make it easier to understand.

| username: magongyong | Original post link

Hmm, I read it once before and forgot, I’ll read it again, thank you.

| username: magongyong | Original post link

Okay, thank you.

| username: magongyong | Original post link

Got it, thanks.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.