mysql跳跃扫描_MySQL 8.0 之索引跳跃扫描(Index Skip Scan)

MySQL 8.0.13引入了索引跳跃扫描(Index Skip Scan),允许在不遵循组合索引最左前缀原则的查询中优化性能。通过示例展示了当查询条件为`f2=40`或`f2>40`时,执行计划显示`using index for skip scan`,显著优于全表扫描。但该特性有限制,如选择的字段必须完全包含在索引中,不支持`GROUP BY`或`DISTINCT`,仅适用于单表查询,且特定的索引结构条件下才能生效。
摘要由CSDN通过智能技术生成

前言

mysql 8.0.13开始支持 index skip scan 也即索引跳跃扫描。该优化方式支持那些sql在不符合组合索引最左前缀的原则的情况,优化器依然能组使用组合索引。

talk is cheap ,show me the code

实践

使用官方文档的例子,构造数据

mysql> create table t1 (f1 int not null, f2 int not null, primary key(f1, f2));

query ok, 0 rows affected (0.21 sec)

mysql> insert into t1 values (1,1), (1,2), (1,3), (1,4), (1,5),(2,1), (2,2), (2,3), (2,4), (2,5);

query ok, 10 rows affected (0.07 sec)

records: 10 duplicates: 0 warnings: 0

mysql>

mysql> insert into t1 select f1, f2 + 5 from t1;

query ok, 10 rows affected (0.06 sec)

records: 10 duplicates: 0 warnings: 0

mysql> insert into t1 select f1, f2 + 10 from t1;

query ok, 20 rows affected (0.03 sec)

records: 20 duplicates: 0 warnings: 0

mysql> insert into t1 select f1, f2 + 20 from t1;

query ok, 40

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值