after the SQL parsing process is complete, you start to enter the optimizer:The process of invocation is divided into: mysql_select:join::p repare:join::optimize:join::exec:prepare Process: Assemble each component, including: Stepup tables, fields, condition, order 1. Tables:setup_tables_and_check_access: Check access from table_list and add tables count to Leaf_tables. Setup_tables&&check_single_table_access 2. Setup_fields
setup_wild: If you use *, this place is to be solved in a field. find_field_in_tables: Find out if a field exists in the table Generate the item as field. 3. setup_without_group setup_conds: Working with where conditions, retrieving fields in Conds setup_order: processing order clauses, retrieving fields in order &NBSP ; setup_group: Working with the group clause, retrieving fields in group optimize procedure: 1. simplify_ Joins: All external connections are changed to internal connections. 2. build_bitmap_for_nested_joins: Establish a bitmap for nested join queries. 3. Optimize_cond: Optimize where conditions remove_eq_conds: Delete equivalent conditions 4. Prune_partitions: Partition pruning, this is only the processing of partitioned tables, non-partitioned tables do not handle 5. make_join_statistics: table->file->stats.records; search LeadsStatistics on the table, table->s->keys: Gets all keys for this table on the Table_share object. update_ref_and_keys: Get index information choose_plan:
Optimize_straight_join:
Find_best:
The process of greedy_search:exec: 1. Do_select: Breaks down join 2. Sub_select:retrieve Records 3. Evaluate_join_record: The next article begins with some experiments: