Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: 请问TIDB的索引结构是什么呢

Is it also a B+Tree like MySQL?
Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: 请问TIDB的索引结构是什么呢
Is it also a B+Tree like MySQL?
The underlying layer of TiDB is RocksDB, a KV database that uses the LSM-Tree data structure.
Both business data and index data are converted into KV key-value pairs for storage. The underlying TiKV can be roughly understood as a huge Map structure. These KV key-value pairs are stored in RocksDB, and the data structure is an LSM tree.
When new data is written in an LSM-Tree structure, it is first written to the in-memory Memtable. The Memtable will periodically or when it reaches a certain size, flush the data to an SSTable on the disk. When the SSTables reach a certain level, they will be compacted into a larger SSTable.
However, when I execute “show index from customer” to look at a table, I see that the index_type shows BTREE. What’s going on?
Initially, it was probably to be compatible with the MySQL 5.7 protocol, merely for compatibility display. The underlying actual storage is not the same.
Tree structure, after watching the related video, it seems to be stored in a KV structure as well.
Indexes are also encoded into KV and stored in TiKV. For encoding rules, see TiDB 数据库的计算 | PingCAP 文档中心
TiKV uses RocksDB as the key-value storage engine at the bottom layer, and the underlying data structure is LSM-tree.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.