MySQL Internals Manual  /  How MySQL Performs Different Selects  /  Steps of Select Execution

12.1 Steps of Select Execution

Every select is performed in these base steps:

  • JOIN::prepare

    • Initialization and linking JOIN structure to st_select_lex.

    • fix_fields() for all items (after fix_fields(), we know everything about item).

    • Moving HAVING to WHERE if possible.

    • Initialization procedure if there is one.

  • JOIN::optimize

    • Single select optimization.

    • Creation of first temporary table if needed.

  • JOIN::exec

    • Performing select (a second temporary table may be created).

  • JOIN::cleanup

    • Removing all temporary tables, other cleanup.

  • JOIN::reinit

    • Prepare all structures for execution of SELECT (with JOIN::exec).