# [KB]关于 TiDB 隐式类型转换导致索引失效

## Description

表上有唯一索引，但是 SQL 执行计划没选择索引，而是全表扫描

```sql
mysql> create table t(a varchar(100), b int, c int, unique key idx(a,b));
Query OK, 0 rows affected (0.08 sec)

mysql> insert into t values(0,0,0),(0,1,1),(1,0,1),(1,1,2);
Query OK, 4 rows affected (0.02 sec)
Records: 4  Duplicates: 0  Warnings: 0

mysql> analyze table t;
Query OK, 0 rows affected, 0 warning (0.11 sec)

mysql> explain select * from t where a=0 and b=1;
+-------------------------+---------+-----------+---------------+-------------------------------------------------------+
| id                      | estRows | task      | access object | operator info                                         |
+-------------------------+---------+-----------+---------------+-------------------------------------------------------+
| TableReader_7           | 0.00    | root      |               | data:Selection_6                                      |
| └─Selection_6           | 0.00    | cop[tikv] |               | eq(cast(test.t.a, double BINARY), 0), eq(test.t.b, 1) |
|   └─TableFullScan_5     | 4.00    | cop[tikv] | table:t       | keep order:false                                      |
+-------------------------+---------+-----------+---------------+-------------------------------------------------------+
3 rows in set (0.00 sec)
```

## Root Cause

SQL 发生隐式类型转换，无法使用索引

## Diagnostic Steps

检查执行计划 operator info 是否存在 cast 函数对字段值做类型转换

## Resolution

修改 SQL，varchar 类型字段值加引号，避免类型转换

## Workaround

N/A

## Affect Version(optional)
