Adjusting the optimizer cost model

To generate execution plans, the optimizer uses a cost model that is based on estimates of the cost of various operations that occur during query execution. The optimizer has a set of compiled-in default cost constants available to it, to make decisions regarding execution plans. You can adjust them by updating or inserting the mysql.engine_cost table and executing the FLUSH OPTIMIZER_COSTS command:

mysql> SELECT * FROM mysql.engine_cost\G*************************** 1. row ***************************  engine_name: InnoDB  device_type: 0    cost_name: io_block_read_cost   cost_value: 1  last_update: 2017-11-20 16:24:56      comment: NULLdefault_value: 1*************************** 2. row *************************** engine_name: ...

Get MySQL 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.