To control optimizer behaviour, we can enable/disable specific optimization via optimizer_switch system variable. The optimizer_switch variable can be changed at runtime, and has global and session values.
Execute the command below to see the current set of optimizer flags.`
SELECT @@optimizer_switch \G
To change the value of optimizer_switch, use the following syntax.
SET [GLOBAL|SESSION] optimizer_switch='cmd[,cmd]...';
Syntax | Description |
default | Reset all optimizations to their default values. |
optimization_name=default | Set the specified optimization to its default value. |
optimization_name=on | Enable the specified optimization. |
optimization_name=off | Disable the specified optimization. |
Cheers!