Instead of adjusting the optimizer switch or optimizer_search_depth variables at session level, you can hint the optimizer to use, or not to use, certain optimizations. The scope of the optimizer hint is limited to the statement that gives you finer control over the queries, whereas the optimizer switch can be at session or global level.
Again, take the example of the preceding query; if you feel that using sort_union is not optimal, you can turn it off by passing it as a hint in the query itself:
mysql> EXPLAIN SELECT /*+ NO_INDEX_MERGE(employees first_name,last_name_2) */ * FROM employees WHERE first_name='Adam' OR last_name='Adam'\G*************************** 1. row *************************** id: 1 select_type: SIMPLE ...