How MySQL executes the associated query

Source: Internet
Author: User

The term ' association ' in MySQL contains a broader sense than the general sense. In general, MySQL considers any query to be an ' association '--not just a query needs to match two tables to be called associations, indexed in MySQL, every query, every fragment (including subqueries, setting up a form-based select) can be associated.

Therefore, it is important to understand how MySQL executes associated queries. Let's look at an example of a union query first. For union queries, MySQL first puts a series of individual query results into a temporary table, and then reads the temporary table data again to complete the union query. In the MySQL concept, each query is an association, so the temporary table that reads the results is also associated.

The current MySQL association execution strategy is simple: MySQL performs a nested association operation on any association, that is, MySQL loops through a table to read a single piece of data, and then finds a matching row in the nested loop to the next table, sequentially until it finds that the matching results in all the tables are unknown. The columns that are required in the query are then returned based on the rows that match each table. MySQL tries to find all the matching rows in the last associated table, and if the last associated table cannot find more rows, MySQL returns to the previous association table to see if more matching records can be found, and so on.

How MySQL executes the associated query

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.