When the MYSQL calculate the scan cost by the method Optimize_table_order::calculate_scan_cost(const JOIN_TAB *tab,....), we know cost does not include the CPU cost during execution for rows that are not filtered out based on the method comments. So the cost calculated by subtracting the rows_after_filtering ,such as below:
scan_and_filter_cost= prefix_rowcount *
(tab->quick()->cost_est.total_cost() +
cost_model->row_evaluate_cost(tab->found_records -
*rows_after_filtering));
scan_and_filter_cost= prefix_rowcount *
(single_scan_read_cost +
cost_model->row_evaluate_cost(tab->records() - *rows_after_filtering));
My question is why the cost does not include the CPU cost during execution for rows that are not filtered out? It should be include it in my mind.
https://github.com/mysql/mysql-server/blob/5.7/sql/sql_planner.cc#L712