I have two columns in a MySQL table, one is startDay varchar(10),like "2020-03-23", the other is orderId archer(20), both of them are nullable
If I create a joint index on (orderId, startDay)
select * from table where orderId is null and startDay < '2020-03-23'
select * from table where orderId is not null and startDay < '2020-03-23'
for the above 2 sql statements, I have two questions: 1) does the first statement use both columns in the joint index? since there are tens of millions of rows, if the statement doesn't use both, but only use part of the index (namely the first one), then the performance may be low?
2) the second one can't use the joint index? why?