MySQL explain analysis Query

Source: Internet
Author: User

MySQL explain analysis Query

Brief description:

You can use the EXPLAIN or DESC keyword to simulate the optimizer to execute SQL query statements to know how MySQL processes your SQL statements. This helps you analyze the performance bottleneck of your query statement or table structure.

Run the explain command to obtain the following information:

1. Reading sequence of tables

2. Read operation type of the table

3. Which indexes can be used?

4. Which indexes are actually used?

5. Reference between tables

6. How many rows are queried by optimizer in each table

Why use explain:

Explain helps us analyze the select statement and let us know why the query efficiency is low, so as to improve our query and make the query optimizer better work.

How does the MySQL query optimizer work:

The MySQL query optimizer has several goals, but the primary goal is to use the index as much as possible and use the strictest index to eliminate as many data rows as possible.

The final goal is to submit a SELECT statement to search for data rows, rather than exclude data rows.

The reason the optimizer tries to exclude data rows is that the faster it can exclude data rows, the faster it can find data rows that match conditions.

If you can perform the strictest test first, the query can be executed faster.

Limitations of explain:

1. explain won't tell you about triggers, stored procedure information, or the impact of user-defined functions on queries.

2. explain does not consider cache.

# The ideal of life is for ideal life! #

This article permanently updates the link address:

Related Article

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.