Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: RocksDB中 Level 0层的数据是单一排序存储吗?
【TiDB Usage Environment】Production\Testing Environment\POC
【TiDB Version】
【Encountered Issues】
【Reproduction Path】What operations were performed that led to the issue
【Issue Phenomenon and Impact】
【Attachments】
- Relevant logs, configuration files, Grafana monitoring (https://metricstool.pingcap.com/)
- TiUP Cluster Display information
- TiUP Cluster Edit config information
- TiDB-Overview monitoring
- Corresponding module’s Grafana monitoring (if any, such as BR, TiDB-binlog, TiCDC, etc.)
- Corresponding module logs (including logs from 1 hour before and after the issue)
If the question is related to performance optimization or troubleshooting, please download the script and run it. Please select all and copy-paste the terminal output results for upload.
The data in level 0 and Immtable is consistent and unordered.
From level 0 to level 1, sorting and compression will be performed…
That is, the data in level 1 is ordered.
Level0 is directly obtained by flushing the Immutable Memtable, and the K/V in the file will not be sorted.
For Level-0 files, RocksDB always selects all files for compaction because there may be key range overlaps between Level-0 files.
For Level-N (N>1) files, they are first sorted by file size (bubble sort), the largest file is selected, and the key range of this file is calculated. Using this range, Level-N+1 files are searched. The selected Level-N file and Level-N+1 files are used as input, and one or more new SST files are created in Level-N+1 as output.
Within L0, individual SST files are ordered internally, but there may be overlapping keys between SST files, so the data in L0 can be considered globally unordered.
The explanation is clear, thank you.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.