Retired Note 1 # MySQL = lambdasql: SQL + & amp; #39; SourceCode4ExplainPlan & amp; #39;

Source: Internet
Author: User

Retired Note 1 # MySQL = lambdasql: SQL + & #39; SourceCode4ExplainPlan & #39;

The Mysql query execution process is roughly divided into four stages:

Syntax analysis (SQL _parse.cc <lexical analysis, syntax analysis, semantic check>)

> SQL _resolver.cc # JOIN. prepare

Generate logical query plan (SQL _optimizer.cc)

>># JOIN. optimize

Generate a physical query plan (SQL _planner.cc)

Run the explain plan (SQL _executor.cc) JOIN.exe c

JOIN. prepare ():

Remove redundant sub-queries

In subquery optimization resolve_subquery ()

Converts all/any subqueries to min/max to optimize simple subqueries.


JOIN. optimize ():

Pull flatten_subqueries () on the subquery ()

Optimize external connection to internal connection simplify_joins ()

Eliminate nested connections

Where clause, join/on clause, having clause simplification, expression simplification containing constants, equality merge optimize_cond () opt_sum_query ()

Optimize count (*) min () man () without the group by clause ()

Determine the multi-Table connection path make_join_statistice ()

Optimize distinct

Create temporary table store temporary results optimize group sorting choose_table_order ()

In fact, logical and physical optimization is a bit confusing and ambiguous,

After the physical query is optimized, some logic optimization is continued.

There are only two ways to scan a single table:

Index scan (others), table scan (JT_ALL)

Opt_range.h> class QUICK_SELECT_ I> use the index scanning drop-down Interface

For the child classes, see source code;

Main classes and struct:

Query tree class st_select_lex

Index struct st_key_create_information class Key_part_spec

Connection table st_join_table

JOIN: public SQL _alloc

Condition COND_EQUAL

Location struct st_position

Cost Estimation Cost_estimate

SELECT NOW(),CURDATE(),CURTIME()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.