Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: min 和limit 1无法查询出结果。
[TiDB Usage Environment] Production Environment
[TiDB Version] 5.7.25-TiDB-v5.1.1 TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible
[Encountered Problem]
[Reproduction Path] What operations were performed to encounter the problem
[Problem Phenomenon and Impact]
Table Structure:
CREATE TABLE snapshot
(
id
bigint(20) NOT NULL AUTO_INCREMENT COMMENT ‘Primary Key’,
tag_id
bigint(20) NOT NULL DEFAULT ‘0’ COMMENT ‘tagid’,
tag_version
bigint(20) NOT NULL DEFAULT ‘0’ COMMENT ‘Data Version’,
PRIMARY KEY (id
) /*T![clustered_index] CLUSTERED */
)
Problem:
select min(id) from snapshot
andSELECT * FROM snapshot limit 1
cannot produce results.- However,
select max(id) from snapshot
produces results in about 50 milliseconds. - When running
select min(id) from snapshot
, thetikv-details-rocksdb-kv seek operations
shows an increase innext
andnext_found
. - The entire table has approximately 1.2 billion rows.
- Suspected to be related to GC? But no data deletion operations have been performed in the last two days. GC configuration:
±-----------------------±-------+
| Variable_name | Value |
±-----------------------±-------+
| tidb_gc_concurrency | -1 |
| tidb_gc_enable | ON |
| tidb_gc_life_time | 10m0s |
| tidb_gc_run_interval | 10m0s |
| tidb_gc_scan_lock_mode | LEGACY |
±-----------------------±-------+
[Attachment]