Is TableRangeScan a primary key query?

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

Original topic: TableRangeScan是走的主键查询吗

| username: chenhanneu

[TiDB Usage Environment] Production Environment / Testing / PoC
[TiDB Version]
[Reproduction Path] What operations were performed to encounter the issue
[Encountered Issue: Issue Phenomenon and Impact]

  • TableFullScan: Full table scan.
  • TableRangeScan: Table data scan with a range.
  • TableRowIDScan: Scanning table data based on RowID passed from the upper layer. Often retrieves rows that meet the criteria after an index read operation.
  • IndexFullScan: Another type of “full table scan,” but it scans index data, not table data.
  • IndexRangeScan: Index data scan operation with a range.

In MySQL, using the primary key to query a portion of data:
±—±------------±---------------±------±--------------±--------±--------±-----±-----±------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
±—±------------±---------------±------±--------------±--------±--------±-----±-----±------------+
| 1 | SIMPLE | test | range | PRIMARY | PRIMARY | 292 | NULL | 192 | Using where |
±—±------------±---------------±------±--------------±--------±--------±-----±-----±------------+

Is TableRangeScan unique to TiDB? When using TableRangeScan, will it use the primary key? If it does, can it also be called “primary indexrangescan”?
[Resource Configuration]
[Attachments: Screenshots/Logs/Monitoring]

| username: zhanggame1 | Original post link

It is unique. By default, a clustered table is sorted by the primary key.

| username: redgame | Original post link

Specifically. It will be used. Super nickname…

| username: tidb菜鸟一只 | Original post link

The underlying structure of TiDB is key-value. If it is a clustered index table, the key of the table is table_id + primary key id. In this way, when querying by primary key, a single value will use point lookup, which TiDB calls Point_Get. For multiple values, it will use TableRangeScan. There is no need to go through the index and then return to the table; the key is directly generated, and the corresponding value is retrieved from TiKV, which is the required data.

| username: cy6301567 | Original post link

The TableRangeScan operation is typically used for primary key range queries. In TiDB, the primary key is a keyword used to uniquely identify each data record. The TableRangeScan operation allows you to retrieve data records within a specific primary key range, which is commonly used for range queries, pagination queries, or other queries that require primary key order.

| username: system | Original post link

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