02-msyql- storage engine

1. optimizer algorithm for indexing

1.1MySQL self-optimization index -AHI (Adaptive HASH index)

MySQL's InnoDB engine, can be created only Btree.
AHI action: 
Automatically evaluating "hot" memory index page, generating a HASH table index.
InnoDB help fast read index page. Read speed up the index read.
Quite indexing and index.

Self-optimizing -Change buffer 1.2MySQL index

Such as insert, update, delete data.
It will be updated immediately for the clustered index.
For the secondary index is not updated in real time.
In the InnoDB memory structure, by adding the insert buffer (session), the current version is called change buffer.
Change buffer function is to temporarily buffer data secondary indexes need updating.
When we need a new insert query data, it will be merge (merge) operation in memory, when the secondary index is the latest

1.3 Introduction optimization algorithm

mysql> select @@optimizer_switch;
index_merge=on,
index_merge_union=on,
index_merge_sort_union=on,
index_merge_intersection=on,
engine_condition_pushdown=on,
index_condition_pushdown=on,
mrr=on,mrr_cost_based=on,
block_nested_loop=on,
batched_key_access=off,
materialization=on,
semijoin=on,
loosescan=on,
firstmatch=on,
duplicateweedout=on,
subquery_materialization_cost_based=on,
use_index_extensions=on,
condition_fanout_filter=on,
derived_merge = on | 

modifications:
1. Change the my.cnf file
2.MySQL> set global optimizer_switch = 'batched_key_access = on'; opened algorithm

1.4 ICP index pushdown

1  resolved, joint index only part of the application.
2  In order to reduce unnecessary data page is scanned.
3  condition will not go index, c do first prior engine data fetch secondary filtration layer.
4 unrelated data will be filtered out in advance.

1.5 MRR   (muti range read)

Secondary indexes back to the table ---- ---> clustered indexes
Converted to
Secondary indexes ---> sort id - back to the table -> clustered index  
Role: Sort secondary indexes back to the table to a clustered index

1.6 BNLJ

When A and B match the associated condition is no longer circulated again and again.
The associated values ​​instead of using a disposable non-driven and driven table matching table disposable return result
The main optimized, CPU consumption, reducing the number of IO

1.7 BKA

The main role, to optimize the use of non-driving related table lists the secondary index.
BNL + MRR functions.
Open the way: 
mysql> set global optimizer_switch='mrr=on,mrr_cost_based=off';
mysql> set global optimizer_switch='batched_key_access=on';
Re-login to take effect.

 

Guess you like

Origin www.cnblogs.com/metoyou/p/12341068.html