Tried 3 different ways.
1st
explain select * from test where create_time like '2019-10%';
id|select_type|table|partitions|type|possible_keys |key|key_len|ref|rows |filtered|Extra |
--|-----------|-----|----------|----|--------------------|---|-------|---|-----|--------|-----------|
1|SIMPLE |test | |ALL |test_create_time_IDX| | | |10376| 11.11|Using where|
2nd
explain select * from test where create_time between '2019-10-01 00:00:00' and '2019-10-31 23:59:59';
id|select_type|table|partitions|type |possible_keys |key |key_len|ref|rows|filtered|Extra |
--|-----------|-----|----------|-----|--------------------|--------------------|-------|---|----|--------|---------------------|
1|SIMPLE |test | |range|test_create_time_IDX|test_create_time_IDX|6 | | 5| 100|Using index condition|
3rd
explain select * from test where date_format(create_time,'%Y-%m') = '2019-10';
id|select_type|table|partitions|type|possible_keys|key|key_len|ref|rows |filtered|Extra |
--|-----------|-----|----------|----|-------------|---|-------|---|-----|--------|-----------|
1|SIMPLE |test | |ALL | | | | |10376| 100|Using where|
I was told that "like 'pattern%'" will use the index."like '%pattern%'","like '%pattern'" won't.
But on the 1st condition it didn't work out as i thought.Is it because the column type of create_time is DATETIME?
And I can't find details about difference of all these "like" SQLs while interacting with indexes in official reference manual.
Can somenone pls share a official link with me?(All I got is hearsay)