Mysql get Optimizer Trace
-- Step 1: Enable optimizer trace
SET optimizer_trace="enabled=on";
-- Step 2: Run the query
SELECT COUNT(\*) FROM table_name;
-- Step 3: Retrieve the optimizer trace
SELECT \* FROM information_schema.OPTIMIZER_TRACE;
-- Step 4: Disable the optimizer trace
SET optimizer_trace="enabled=off";