Skip to content

index time range got a over-estimation compared with v7.5.3 #65294

@AilinKid

Description

@AilinKid

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql> plan replayer load '/Users/tailingxiang/Downloads/replayer_4sl0h-c6Ucp4ioSjQFJ4Vw==_1766724135378196957.zip';
Query OK, 0 rows affected (0.203 sec)

mysql> explain format="verbose" SELECT  * FROM db.table WHERE col_time >= '2025-12-22 04:00:00' AND col_time < '2025-12-22 05:00:00';
+-------------------------------+----------+--------------+-----------+--------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id                            | estRows  | estCost      | task      | access object                                                | operator info                                                                                                                                                                          |
+-------------------------------+----------+--------------+-----------+--------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| IndexLookUp_8                 | 52187.58 | 103350518.05 | root      |                                                              |                                                                                                                                                                                        |
| ├─IndexRangeScan_6(Build)     | 52187.58 | 10620171.98  | cop[tikv] | table:table, index:index(col_time)                           | range:[2025-12-22 04:00:00,2025-12-22 05:00:00), keep order:false, stats:partial[uk_id:allEvicted, idx_session:allEvicted, idx_item:allEvicted...(more: 3 allEvicted)]                 |
| └─TableRowIDScan_7(Probe)     | 52187.58 | 19511254.35  | cop[tikv] | table:table                                                  | keep order:false, stats:partial[uk_id:allEvicted, idx_session:allEvicted, idx_item:allEvicted...(more: 3 allEvicted)]                                                                    |
+-------------------------------+----------+--------------+-----------+--------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
3 rows in set, 1 warning (0.007 sec)

mysql> select version();
+--------------------------+
| version()                |
+--------------------------+
| 8.0.11-TiDB-v7.5.3-dirty |
+--------------------------+
1 row in set (0.005 sec)

mysql> plan replayer load '/Users/tailingxiang/Downloads/replayer_4sl0h-c6Ucp4ioSjQFJ4Vw==_1766724135378196957.zip';
Query OK, 0 rows affected (0.203 sec)

mysql> explain format="verbose" SELECT  * FROM db.table WHERE col_time >= '2025-12-22 04:00:00' AND col_time < '2025-12-22 05:00:00';
+--------------------------------+-------------+----------------+-----------+--------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id                             | estRows     | estCost        | task      | access object                                                | operator info                                                                                                                                                                                      |
+--------------------------------+-------------+----------------+-----------+--------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| IndexLookUp_11                 | 10091419.40 | 19826583302.42 | root      |                                                              |                                                                                                                                                                                                    |
| ├─IndexRangeScan_9(Build)      | 10091419.40 | 2053603847.90  | cop[tikv] | table:table, index:index(col_time)                           | range:[2025-12-22 04:00:00,2025-12-22 05:00:00), keep order:false, stats:partial[uk_id:unInitialized, idx_session:unInitialized, idx_item:unInitialized...(more: 2 unInitialized)]               |
| └─TableRowIDScan_10(Probe)     | 10091419.40 | 4319016330.25  | cop[tikv] | table:table                                                  | keep order:false, stats:partial[uk_id:unInitialized, idx_session:unInitialized, idx_item:unInitialized...(more: 2 unInitialized)]                                                                  |
+--------------------------------+-------------+----------------+-----------+--------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
3 rows in set, 1 warning (0.006 sec)

mysql> select version();
+-----------------------------------------------------+
| version()                                           |
+-----------------------------------------------------+
| 8.0.11-TiDB-v8.5.4-nextgen.202510.0-263-g704d4c88f0 |
+-----------------------------------------------------+
1 row in set (0.000 sec)

2. What did you expect to see? (Required)

next gen have some over estimation of index time range, not sure it's intended or not. while the actually is quite lower then expected

Image

3. What did you see instead (Required)

normal estimation as before, pls feel free to reach me to get the replayer

4. What is your TiDB version? (Required)

next-gen & master

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions