-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Labels
affects-6.5This bug affects the 6.5.x(LTS) versions.This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.This bug affects the 8.1.x(LTS) versions.report/customerCustomers have encountered this bug.Customers have encountered this bug.severity/majorsig/plannerSIG: PlannerSIG: Plannertype/bugThe issue is confirmed as a bug.The issue is confirmed as a bug.type/regression
Description
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
mysql> create table t (
id int,
`deleted_at` datetime(3) NOT NULL DEFAULT '1970-01-01 01:00:01.000',
`is_deleted` tinyint(1) GENERATED ALWAYS AS ((`deleted_at` > _utf8mb4'1970-01-01 01:00:01.000')) VIRTUAL NOT NULL,
key k(id, is_deleted)
);
Query OK, 0 rows affected (0.02 sec)
mysql>
mysql> begin;
Query OK, 0 rows affected (0.01 sec)
mysql> insert into t (id, deleted_at) values (1, now());
Query OK, 1 row affected (0.00 sec)
mysql> explain select 1 from t where id=1 and is_deleted=true;
+------------------------------+----------+-----------+----------------------------------+--------------------------------------------+
| id | estRows | task | access object | operator info |
+------------------------------+----------+-----------+----------------------------------+--------------------------------------------+
| Projection_5 | 8000.00 | root | | 1->Column#5 |
| └─Selection_6 | 8000.00 | root | | eq(test.t.id, 1), eq(test.t.is_deleted, 1) |
| └─UnionScan_7 | 10000.00 | root | | |
| └─IndexReader_12 | 10000.00 | root | | index:IndexFullScan_11 |
| └─IndexFullScan_11 | 10000.00 | cop[tikv] | table:t, index:k(id, is_deleted) | keep order:false, stats:pseudo |
+------------------------------+----------+-----------+----------------------------------+--------------------------------------------+
5 rows in set (0.00 sec)
2. What did you expect to see? (Required)
The plan should use IndexRangeScan
.
3. What did you see instead (Required)
IndexFullScan
4. What is your TiDB version? (Required)
Metadata
Metadata
Assignees
Labels
affects-6.5This bug affects the 6.5.x(LTS) versions.This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.This bug affects the 8.1.x(LTS) versions.report/customerCustomers have encountered this bug.Customers have encountered this bug.severity/majorsig/plannerSIG: PlannerSIG: Plannertype/bugThe issue is confirmed as a bug.The issue is confirmed as a bug.type/regression