-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Labels
epic/plan-cachesig/plannerSIG: PlannerSIG: Plannertype/enhancementThe issue or PR belongs to an enhancement.The issue or PR belongs to an enhancement.
Description
Enhancement
mysql> create table t (a int, key(a));
Query OK, 0 rows affected (0.05 sec)
mysql> prepare st from 'select * from t use index(a) where a < ?';
Query OK, 0 rows affected (0.01 sec)
mysql> set @a1=1.1;
Query OK, 0 rows affected (0.00 sec)
mysql> execute st using @a1; -- sub-optimal plan with fullscan
Empty set (0.01 sec)
+---------------------------+----------+---------+-----------+---------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------+--------+------+
| id | estRows | actRows | task | access object | execution info | operator info | memory | disk |
+---------------------------+----------+---------+-----------+---------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------+--------+------+
| Selection_8 | 8000.00 | 0 | root | | time:1.05ms, loops:1 | lt(cast(test.t.a, decimal(10,0) BINARY), 1.1) | N/A | N/A |
| └─IndexReader_7 | 8000.00 | 0 | root | | time:1.04ms, loops:1, cop_task: {num: 1, max: 898.4µs, proc_keys: 0, rpc_num: 1, rpc_time: 814.5µs, copr_cache_hit_ratio: 0.00, distsql_concurrency: 15} | index:Selection_6 | N/A | N/A |
| └─Selection_6 | 8000.00 | 0 | cop[tikv] | | tikv_task:{time:706µs, loops:0} | lt(cast(test.t.a, decimal(10,0) BINARY), 1.1) | N/A | N/A |
| └─IndexFullScan_5 | 10000.00 | 0 | cop[tikv] | table:t, index:a(a) | tikv_task:{time:706µs, loops:0} | keep order:false, stats:pseudo | N/A | N/A |
+---------------------------+----------+---------+-----------+---------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------+--------+------+
mysql> explain select * from t use index(a) where a < 1.1; -- range scan
+------------------------+---------+-----------+---------------------+------------------------------------------------+
| id | estRows | task | access object | operator info |
+------------------------+---------+-----------+---------------------+------------------------------------------------+
| IndexReader_6 | 3323.33 | root | | index:IndexRangeScan_5 |
| └─IndexRangeScan_5 | 3323.33 | cop[tikv] | table:t, index:a(a) | range:[-inf,2), keep order:false, stats:pseudo |
+------------------------+---------+-----------+---------------------+------------------------------------------------+
2 rows in set (0.01 sec)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
epic/plan-cachesig/plannerSIG: PlannerSIG: Plannertype/enhancementThe issue or PR belongs to an enhancement.The issue or PR belongs to an enhancement.