sql_optimizer

 PDF

MySQL Optimizer Overview

# Logical transformations:
            - Outer to inner joins transformation.
            - Negation elimination.                   #####   否认消除 not ( t1.a > 10 OR t2.b > 3) => (t1.a <=10 AND t2.b <= 3)
            - Equality/constant propagation.    #####   等式和常量传播 t1.a = t2.a AND t2.a = 9 AND (t1.a <= 10  AND  t2.b <=3 OR (t1.b = t2.b + 7 AND t2.b = 5)) => t1.a = 9 AND t2.a = 9 AND (9 <= 10  AND  t2.b <=3 OR (t1.b = 5 + 7 AND t2.b = 5))
            - Evaluate const expressions.       #####   求常量值 t1.a = 9 AND t2.a = 9 AND (9 <= 10  AND  t2.b <=3 OR (t1.b = 5 + 7 AND t2.b = 5)) => t1.a = 9 AND t2.a = 9 AND (9 <= 10  AND  t2.b <=3 OR (t1.b = 12 AND t2.b = 5))
            - Trivial condtion removal.             #####   不重要的条件移除 t1.a = 9 AND t2.a = 9 AND (9 <= 10  AND  t2.b <=3 OR (t1.b = 12 AND t2.b = 5)) => t1.a = 9 AND t2.a = 9 AND (t2.b <=3 OR (t1.b = 12 AND t2.b = 5))
            - Partition pruning.                         #####  分区修剪是一种非常有效的性能特性。分析修剪分析SQL中的WHERE 和FROM字句,从而在查询中消除不不必要分区
            - COUNT(*), MIN(), MAX() constant substitution in case of implicit grouping.
            - ORDER BY optimization.

           

 

# Perform cost-based optimization of table order and access path selection. See JOIN::make_join_plan()
            - Assign cost to operations
                       The main cost-based optimization: 
                              Index and access method: 
                              Table scan (表扫)
                              Index scan (索引扫)
                              Range scan (范围扫)
                              Index lookup (ref access) (索引查找(通过索引扫再引用访问原表))
                             Join order ()
                             Join buffering strategy ()
                              Subquery strategy ()

                     Cost Estimate (消耗估算)
                            The cost for executing a query 
                             Cost unit: 消耗单元
                                      read a random data page from disk 读取随机页
                                      Main cost factors: 消耗因素(CPU IO)
                                               IO cost:  
                                                    #pages read from table 从表中读页
                                                    #pages read from index 从索引中读页
                                               CPU cost: 
                                                    Evaluating query conditions 评估查询条件
                                                    Comparing keys/records 比较键和记录
                                                    Sorting keys 排序键

- Assign cost to partial or alternative plans
- Search for plan with lowest cost

转载于:https://www.cnblogs.com/hyming011/p/8251864.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值