mysql> explain select * from user_risk where risk_value='xxxxx' AND risk_item = 1 and risk_type = 1 and is_deleted = 0 and status = 1;
+--------------------------------+---------+-----------+---------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| id | estRows | task | access object | operator info |
+--------------------------------+---------+-----------+---------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| IndexLookUp_15 | 1.06 | root | | |
| ├─IndexRangeScan_12(Build) | 1.10 | cop[tikv] | table:user_risk, index:idx_risk_value(risk_item, risk_type, risk_value) | range:[1 1 "xxx",1 1 "xxx"], keep order:false |
| └─Selection_14(Probe) | 1.06 | cop[tikv] | | eq(user_risk.is_deleted, 0), eq(user_risk.status, 1) |
| └─TableRowIDScan_13 | 1.10 | cop[tikv] | table:user_risk | keep order:false |
+--------------------------------+---------+-----------+---------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
4 rows in set (0.01 sec)
这种就可以使用索引,即使是回表也用到了索引,一旦risk_value=(子查询)或risk_value in (子查询)就违背常理的慢