-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Labels
component/statisticscomponent/tablepartitionThis issue is related to Table Partition of TiDB.This issue is related to Table Partition of TiDB.sig/plannerSIG: PlannerSIG: Plannertype/enhancementThe issue or PR belongs to an enhancement.The issue or PR belongs to an enhancement.
Description
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
set tidb_enable_global_index=true;
drop table if exists t;
CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
UNIQUE KEY `idx` ((`c` + 1)),
UNIQUE KEY `idx1` (`c`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY HASH (`b`) PARTITIONS 2;
insert into t values (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5);
analyze table t;
explain select c+1 from t where (c+1)>3;
2. What did you expect to see? (Required)
mysql> explain select c+1 from t where (c+1)>3;
+------------------------+---------+-----------+------------------------------+--------------------------------------------------------------------------+
| id | estRows | task | access object | operator info |
+------------------------+---------+-----------+------------------------------+--------------------------------------------------------------------------+
| IndexReader_6 | 3.00 | root | | index:IndexRangeScan_5 |
| └─IndexRangeScan_5 | 3.00 | cop[tikv] | table:t, index:idx(`c` + 1) | range:(3,+inf], keep order:false, stats:partial[_v$_idx_0:unInitialized] |
+------------------------+---------+-----------+------------------------------+--------------------------------------------------------------------------+
2 rows in set (0.01 sec)
3. What did you see instead (Required)
mysql> explain select c+1 from t where (c+1)>3;
+------------------------+---------+-----------+-----------------------------+--------------------------------------------------------------------------+
| id | estRows | task | access object | operator info |
+------------------------+---------+-----------+-----------------------------+--------------------------------------------------------------------------+
| IndexReader_7 | 2.08 | root | partition:all | index:IndexRangeScan_5 |
| └─IndexRangeScan_5 | 2.08 | cop[tikv] | table:t, index:idx(`c` + 1) | range:(3,+inf], keep order:false, stats:partial[_v$_idx_0:unInitialized] |
+------------------------+---------+-----------+-----------------------------+--------------------------------------------------------------------------+
2 rows in set (0.01 sec)
The estRows are never changed, no matter what conditions are used to query, e.g. explain select c+1 from t where (c+1)>0;
4. What is your TiDB version? (Required)
Metadata
Metadata
Assignees
Labels
component/statisticscomponent/tablepartitionThis issue is related to Table Partition of TiDB.This issue is related to Table Partition of TiDB.sig/plannerSIG: PlannerSIG: Plannertype/enhancementThe issue or PR belongs to an enhancement.The issue or PR belongs to an enhancement.