I know there is already similar question here like How does the database decide which Index to use. But it seems that those answers are not cool and useless.
In my development and use of MySQL, I found there are multiple factors that affect how MySQL decides which index should be used to execute the SQL statements. Those factors include but are not limited to:
The estimated scan count of rows for certain index.
order bycondition and whether certain index would cause
The presence of
limit 0,Ncondition and even the value of N would impact the result.
Any response from people who have read the source code or have developed MySQL source codes will be highly appreciated! :)
If you know someone who maybe knows the answers, please share this page with them.