pingcap/tidb
View on GitHubplanner: warn if manual hints are overwritten by bindings
Open
#68550 opened on May 21, 2026
good first issuehelp wantedreport/customersig/plannertype/enhancement
Description
Enhancement
In the example below, the user wants to use a hint to force the optimizer to use index b, but it's still using index a, since a binding overwrites the hint. We should warn in this scenario to avoid confusing users.
mysql> create table t (a int, b int, key(a), key(b));
Query OK, 0 rows affected (0.016 sec)
mysql> create global binding using select /*+ use_index(t, a) */ * from t where a=1 and b=1;
Query OK, 0 rows affected (0.006 sec)
mysql> explain select /*+ use_index(t, b) */ * from t where a=1 and b=1;
+-------------------------------+---------+-----------+---------------------+---------------------------------------------+
| id | estRows | task | access object | operator info |
+-------------------------------+---------+-----------+---------------------+---------------------------------------------+
| IndexLookUp_8 | 0.01 | root | | |
| ├─IndexRangeScan_5(Build) | 10.00 | cop[tikv] | table:t, index:a(a) | range:[1,1], keep order:false, stats:pseudo |
| └─Selection_7(Probe) | 0.01 | cop[tikv] | | eq(test.t.b, 1) |
| └─TableRowIDScan_6 | 10.00 | cop[tikv] | table:t | keep order:false, stats:pseudo |
+-------------------------------+---------+-----------+---------------------+---------------------------------------------+