Does MySQL exectution plan depend on available indexes? Does MySQL choose an execution plan for a given query taking into account what indexes are available, or does it first choose an execution plan and then uses indexes if they are available?

Motivation: I want to decide which indexes would be useful. I have a number of typical queries. So I can imagine two possible strategies:


If the plans do not depend on available indexes: see the execution plans of those queries and add indexes useful for these plans, or
If the plans depend on available indexes: add all possible indexes (a lot!), see the plans for the queries, and remove unused indexes.


My DB is not very large, so I can afford playing with indexes. I currently use InnoDB, but I can switch to MyISAM or another if needed.
MySQL's optimizer looks only at what indexes are available.

There is an exception in 5.6:  If you have a subqueries such as
FROM ( SELECT ... ) JOIN ( SELECT ... ) ..., there are no indexes on the temporary tables that are created.  This used to lead to terrible performance.  Now, the optimizer will try out various indexes, and create the best one for the tmp table.  I suspect it only looks for single-column indexes, not "compound" indexes

InnoDB is getting the most attention these days.  MyISAM does not have any tricks up its sleeve.

Try out my Cookbook for creating the best index, given a SELECT.  It may save you some false starts.