Execute SQL query statement

Implementation process

  • Connector - manage the connection, verify permissions
  • Query cache - cache hit directly return results
  • Analyzer - lexical analysis, parsing
  • Optimizer - analysis of the implementation plan, choose the best execution plan
  • Actuator - Interface storage engine operation, returns the result

Different storage engines share one Server Layer

Connector

The connector is responsible for establishing a connection with the client, access permissions, maintain and manage connections

If the client is not too long movement, the connection will automatically be disconnected. This time is controlled by parameters wait_timeout.

After the connection is broken, the continuing need reconnect to execute client requests.

Database connections are usually recommended for long connection.

Query Cache

  • Get a query request, the query cache will first see whether performed prior to this statement.
  • Statement is not in the query cache query phase, we will continue behind.
  • After the execution is completed, the results will be stored in the query cache.

Query cache expiration very frequently, as long as there is an update to a table, all of this will be on the table query cache is emptied.

Update pressure for large databases, the query cache hit rate is very low.

8.0 completely free of this function

Analyzer

Do the parsing of SQL statements

  • Do first lexical analysis . What parsing strings are what representatives.
  • Then parsing , lexical analysis of the results, according to the rules of grammar parser will judge you enter this SQL statement meets the MySQL syntax.

Optimizer

The role of the optimizer is to decide to choose which program execution efficiency of the use of higher.

such as:

  • Table there are multiple indexes when deciding which index to use.
  • Or a statement has a multi-table associated with the time (join), determines the order of connection of each table

After optimizer phase is complete, the implementation of the program statement to be finalized, and then enter the actuator stage.

Actuator

By optimizer knows how to do, so he entered the stage actuator.

Open the table, the actuator will be defined according to the table of the engine, this engine provides the interface to use, and conduct.

Slow query log

rows_examined field, indicating that the statement execution scanning process the number of lines.

Guess you like

Origin www.cnblogs.com/ginko/p/11609453.html