Block Nested-loop and batched Key Access

Source: Internet
Author: User

Official Document: Https://dev.mysql.com/doc/refman/5.7/en/bnl-bka-optimization.html

BNL and BKA are two relational algorithms associated with MySQL tables

For example, T1, T2, T3 associated queries and query Order and association order consistent, MySQL processing join process is generally

T1 and T2 's associated result set are placed in the join buffer B1, when assigned to the join buffer, the varchar type field is the smallest allocation unit, so varchar also specifies the appropriate length to avoid wasting memory.

The result set in the B1 is then matched to T3, and the matching result set is placed in the join buffer b2,b2 is the delta buffer, because B2 stores the T3 matching column and the location link of the row that matches it

The Bnl,explain output extra is a using join buffer (Block Nested Loop) when the query type of the inner table is all, index, or range

Bak and BNL do not lie in the secondary index when all the right and left result sets match. Bak commits the T2-to-multi-range Read (MRR) interface associated with the B1 in one-time to the index of the T2

Matches, and then returns the matching key sorted by primary key by MRR, thereby reducing the random I/O generated when the table is returned. The size of the join_buffer_size determines the size of the key that Bak submits to MRR each time the batch is processed,

Appropriately increasing the size of join_buffer_size can effectively improve the performance of correlated queries.

When the query type of the inner table is ref or EQ_REF, the join takes bak,explain extra output as a using join buffer (batched Key Access)

BNL is turned on by default, and Bka is turned off by default, if you want to turn Bak on, you need to start together MRR

MySQL>SET optimizer_switch='mrr=on,mrr_cost_based=off,batched_key_ Access=on';

Block Nested-loop and batched Key Access

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.