Skip to content

Reporting a tablefullscan When I read the data between invalid data due to DST #61335

@kissmydb

Description

@kissmydb

Bug Report

Please answer these questions before submitting your issue. Thanks!

If there is DST happen, the time '2025-03-30 02:00:00'~'2025-03-30 02:59:00' is not exist. When I read the data between invalid data , Resulting almost read all the data which is not expacted. And if I use a valid data , the explain is normal.

1. Minimal reproduce step (Required)

mysql> SET GLOBAL time_zone = 'Europe/Stockholm';
Query OK, 0 rows affected (0.01 sec)

Create Table: CREATE TABLE `orders` (
  `id` int DEFAULT NULL,
  `created` timestamp NULL DEFAULT NULL,
  KEY `idx_create` (`created`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
1 row in set (0.00 sec)

mysql> explain select *  from orders  where created between '2025-03-30 02:01:59'   and '2025-03-30 03:00:01' order by 2;
+--------------------------------+--------------+-----------+------------------------------------------------+-------------------------------------------------------------------------+
| id                             | estRows      | task      | access object                                  | operator info                                                           |
+--------------------------------+--------------+-----------+------------------------------------------------+-------------------------------------------------------------------------+
| IndexLookUp_17                 | 103218635.00 | root      |                                                |                                                                         |
| ├─IndexRangeScan_15(Build)     | 103218635.00 | cop[tikv] | table:orders, index:order_created_idx(created) | range:[2025-03-30 02:01:59.000000,2025-03-30 03:00:01], keep order:true |
| └─TableRowIDScan_16(Probe)     | 103218635.00 | cop[tikv] | table:orders                                   | keep order:false                                                        |
+--------------------------------+--------------+-----------+------------------------------------------------+-------------------------------------------------------------------------+
3 rows in set, 26 warnings (0,024 sec)

mysql> explain select * from orders  where created between '2025-03-30 01:01:59'   and '2025-03-30 03:00:01' order by 2;
+--------------------------------+---------+-----------+------------------------------------------------+------------------------------------------------------------------+
| id                             | estRows | task      | access object                                  | operator info                                                    |
+--------------------------------+---------+-----------+------------------------------------------------+------------------------------------------------------------------+
| IndexLookUp_14                 | 2110.60 | root      |                                                |                                                                  |
| ├─IndexRangeScan_12(Build)     | 2110.60 | cop[tikv] | table:orders, index:order_created_idx(created) | range:[2025-03-30 01:01:59,2025-03-30 03:00:01], keep order:true |
| └─TableRowIDScan_13(Probe)     | 2110.60 | cop[tikv] | table:orders                                   | keep order:false                                                 |
+--------------------------------+---------+-----------+------------------------------------------------+------------------------------------------------------------------+
3 rows in set (0,011 sec)

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

Table

3. What did you see instead (Required)

4. What is your TiDB version? (Required)

v8.5.1

Metadata

Metadata

Assignees

Labels

affects-8.1This bug affects the 8.1.x(LTS) versions.affects-8.5This bug affects the 8.5.x(LTS) versions.severity/majorsig/plannerSIG: Plannertype/bugThe issue is confirmed as a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions