January 2018
Intermediate to advanced
446 pages
12h 57m
English
The optimizer_switch system variable is a set of flags. You can set each of those flags to ON or OFF to enable or disable the corresponding optimizer behavior. You can set it at the session level or global level dynamically. If you adjust the optimizer switch at the session level, all the queries in that session are affected, and if it is at the global level, all queries are affected.
For example, you have noticed that the preceding query, SELECT emp_no FROM employees WHERE first_name='Adam' OR last_name='Adam', is using sort_union(first_name,last_name_2). If you think that optimization is not correct for that query, you can adjust optimizer_switch to switch to another optimization:
mysql> SHOW VARIABLES LIKE 'optimizer_switch'\G ...
Read now
Unlock full access