Does mysql condition use or query trigger index? The statement is: the where condition contains or and does not use indexes. the test results are as follows: mysql & gt; & nbsp; explain & nbsp; select & nbsp; * & nbsp; from & nbsp; emp & nbsp; where & nbsp; ename = "dsleos" & nbsp; mysql condition use or query will not trigger the index?
The statement is: the where condition contains or and does not use the index.
My test results are as follows:
mysql> explain select * from emp where ename="dsleos" or ename="saesad" \G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: emp
type: range
possible_keys: e_i
key: e_i
key_len: 62
ref: NULL
rows: 2
Extra: Using where
1 row in set (0.00 sec)
If the index is triggered, will or trigger the index? Share :? Explain? Select? *? From? Emp? Where? Ename = "dsleos "? O... 'data-pics = ''>
------ Solution --------------------
Of course, the index will be used.
Of course, if you only test the database because the data volume in the database is not large enough, the Mysql engine may intelligently discard the index and directly query the database.
------ Solution --------------------
Or .)