The Optimizer Cost Model SELECT * FROM t USE INDEX (index1) IGNORE INDEX (index1) FOR ORDER BY IGNORE INDEX (index1) FOR GROUP BY WHERE ... IN BOOLEAN MODE ... ; SELECT * FROM t USE INDEX (index1) WHERE ... IN BOOLEAN MODE ... ; 8.9.5 The Optimizer Cost Model Cost Model General Operation 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. The optimizer also has a database of cost estimates to use during execution plan construction. These estimates are stored in the  server_cost  and  engine_cost  tables in the  mysql  system database and are configurable at any time. The intent of these tables is to make it possible to easily adjust the cost estimates that the optimizer uses when it attempts to arrive at query execution plans. •Cost Model General Operation •The Cost Model Database •Making Changes to the Cost Model Database •The server reads the cost model tables into memory at startup and uses the in-memory values at runtime. Any non- NULL  cost estimate specified in the tables takes precedence over the corresponding compiled-in default cost constant. Any  NULL  estimate indicates to the optimizer to use the compiled-in default. •At runtime, the server may re-read the cost tables. This occurs when a storage engine is dynamically loaded or when a  FLUSH OPTIMIZER_COSTS  statement is executed. •Cost tables enable server administrators to easily adjust cost estimates by changing entries in the tables. It is also easy to revert to a default by setting an entry’s cost to  NULL . The optimizer uses the in-memory cost values, so changes to the tables should be followed by  FLUSH OPTIMIZER_COSTS  to take effect. •The in-memory cost estimates that are current when a client session begins apply throughout that session until it ends. In particular, if the server re-reads the cost tables, any changed estimates apply only to subsequently started sessions. Existing sessions are unaffected. •Cost tables are specific to a given server instance. The server does not replicate cost table changes to replicas. •  server_cost : Optimizer cost estimates for general server operations 1809 The Cost Model Database The optimizer cost model database consists of two tables in the  mysql  system database that contain cost estimate information for operations that occur during query execution: The configurable optimizer cost model works like this: