来源: http://dev.mysql.com/worklog/task/?id=6510
EXPLAIN JSON should print cost for following: *) "query_cost" - total cost of a query block, no matter top query or a subquery. *) "sort_cost" - cost of the first sorting operation (GROUP BY or ORDER BY) where and if filesort is used. Cost for second sorting operation isn't printed as optimizer doesn't calculate it. *) "read_cost" - cost of reading for each table used in the query block. *) "eval_cost" - cost of condition evaluation for each table in the query block. *) "prefix_cost" - cost of executing prefix join in the query block.
//"prefix_cost",应该表示的是“之前连接的代价”,但是单表扫描,该变量有值存在,如下图,疑似bug。待查。
//待查之后,验明正身:此值表示自身的cost,所以单表扫描,改变量有值是正确的。所以,如下句的解释说明了此含义:
/* "prefix_cost" cost of executing prefix join, i.e. cost of joining tables of the query block from the first one to the one (and including it) for which the value is given.
*/
*) "data_read_per_join" - estimated amount of data from the table processed during single query block execution. *) "rows_produced_per_join"/"rows_examined_per_scan" estimated number of records from the table (per each table from the query block) produced/examined per single query block execution. *) "used_columns" - list of columns of the table (per each table in the query block) used for either read or write in the query.
另外,还有解释如下:
1) "query_cost" total [sub]query cost per one execution. Wrapped in the "cost_info" node, child of the "query_block" node. For the top-level select should be equal to the 'last_query_cost' status variable. 2) "sort_cost" cost of filesort, independently of algorithm. Wrapped in the "cost_info" node, child of the "ordering_operation" node. 3) "read_cost" cost of retrieving data from table, i.e access method cost. 4) "eval_cost" cost of condition evaluation. 5) "prefix_cost" cost of executing prefix join, i.e. cost of joining tables of the query block from the first one to the one (and including it) for which the value is given.
图片对应MySQL 5.7.