Is there any way to get the optimization time in MySQL? I'd like to see the time optimizer takes to optimize a query. Is there any way to get that time?
yes, you can use profiling, for an example query SELECT * FROM Country LIMIT 5; you will need to do the follow:

mysql&gt; SET profiling = 1;
mysql&gt; SELECT * FROM Country LIMIT 5;
. . .
mysql&gt; SHOW PROFILES;
+----------+------------+-------------------------------+
| Query_ID | Duration   | Query                         |
+----------+------------+-------------------------------+
|        1 | 0.02295675 | SELECT DATABASE()             |
|        2 | 0.00056225 | show databases                |
|        3 | 0.00017600 | show tables                   |
|        4 | 0.00016950 | select * FROM City            |
|        5 | 0.00027725 | show tables                   |
|        6 | 0.07000825 | select * FROM Country LIMIT 5 |
+----------+------------+-------------------------------+
mysql&gt; SHOW PROFILE FOR QUERY 6;
+--------------------------------+----------+
| Status                         | Duration |
+--------------------------------+----------+
| starting                       | 0.000028 |
| Waiting for query cache lock   | 0.000005 |
| checking query cache for query | 0.000034 |
| checking permissions           | 0.000009 |
| Opening tables                 | 0.000735 |
| System lock                    | 0.033283 |
| Waiting for query cache lock   | 0.009419 |
| init                           | 0.000029 |
| optimizing                     | 0.000006 | &lt;--- HERE IS THE OPTIMIZER TIME
| statistics                     | 0.000013 |
| preparing                      | 0.000010 |
| executing                      | 0.000005 |
| Sending data                   | 0.026332 |
| end                            | 0.000014 |
| query end                      | 0.000008 |
| closing tables                 | 0.000027 |
| freeing items                  | 0.000009 |
| Waiting for query cache lock   | 0.000004 |
| freeing items                  | 0.000017 |
| Waiting for query cache lock   | 0.000004 |
| freeing items                  | 0.000005 |
| storing result in query cache  | 0.000007 |
| logging slow query             | 0.000004 |
| cleaning up                    | 0.000005 |
+--------------------------------+----------+
24 rows in set (0.03 sec)


In my example query SELECT * FROM Country LIMIT 5; the optmizer took 0.000006