Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: 非唯一二级索引的 Key 中为什么包括 RowID?
[TiDB Usage Environment] Test
[TiDB Version] 6.5.0
[Reproduction Path] 3.1 表数据与 Key-Value 的映射关系 | tidb-in-action
[Encountered Issues: Phenomenon and Impact]
The document shows:
For a normal secondary index that does not need to meet uniqueness constraints, one key value may correspond to multiple rows. We need to query the corresponding RowID based on the key value range. Therefore, encode it into (Key, Value) key-value pairs according to the following rules:
Key: tablePrefix{TableID}_indexPrefixSep{IndexID}indexedColumnsValue{RowID}
Value: null
There are several questions:
- What does it mean to query the corresponding RowID based on the key value range?
- indexedColumnsValue does not have curly braces {}, so does the key not include the actual value of the index column?
- Why is the Value of a non-unique secondary index null, and how is the index used? Do we extract the RowID from the key and then go back to the table to get the entire row of data?
[Resource Configuration]
[Attachment: Screenshot/Log/Monitoring]