Why does MySQL ignore my index01 (key_part1, key_part2, key_part3) for the following query?
select * from tab where key_part1 is not null and key_part2 is null and key_part3 is null;
All fields are of type "datetime default NULL".
"explain" of this query returns "key: NULL". Why?
If I add "force index index01", explain returns "key: index01" but still shows "rows: 91261", which almost is the cardinality of the table.
If I change the first condition to "key_part1 is null", the index is used, explain returns "key: index01"
What can I do?
select * from tab where key_part1 is not null and key_part2 is null and key_part3 is null;
All fields are of type "datetime default NULL".
"explain" of this query returns "key: NULL". Why?
If I add "force index index01", explain returns "key: index01" but still shows "rows: 91261", which almost is the cardinality of the table.
If I change the first condition to "key_part1 is null", the index is used, explain returns "key: index01"
What can I do?
Comment