重庆思庄Oracle、KingBase、PostgreSQL、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 296|回复: 0
打印 上一主题 下一主题

[参数配置] 并行查询innodb_parallel_read_threads

[复制链接]
跳转到指定楼层
楼主
发表于 2026-1-4 18:13:20 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 jiawang 于 2026-1-4 22:13 编辑

mysql 并行查询_MySQL 8.0新特性-并行查询innodb_parallel_read_threads

本文介绍了MySQL 8.0从8.0.14版本开始引入的并行查询特性,特别是针对无WHERE条件的count(*)操作。通过实验展示了设置不同并行读取线程数对查询性能的影响,揭示了并行查询对性能提升的效果以及潜在的优化限制。
文很好翻译,直接读好理解
下,MySQL终于在8.0.14版本开始有了自己的并行查询,但使用面非常的窄,只适用于并行聚集索引的count(*) 并且只是在没有where条件的情况下的查询

mysql> set local inno
长久以来MySQL没有并行查询,并且在其他数据库已经有了的情况db_parallel_read_threads=1;

Query OK, 0 rows affected (0.00 sec)


mysql> select count(*) from ontime;
+-----------+


| count(*) |


+-----------+


| 177920306 |


+-----------+


1 row in set (2 min 33.93 sec)


mysql> set local innodb_parallel_read_threads=DEFAULT; -- 4 is default


Query OK, 0 rows affected (0.00 sec)


mysql> select count(*) from ontime;


+-----------+


| count(*) |


+-----------+


| 177920306 |


+-----------+


1 row in set (21.85 sec)


mysql> set local innodb_parallel_read_threads=32;


Query OK, 0 rows affected (0.00 sec)


mysql> select count(*) from ontime;


+-----------+


| count(*) |


+-----------+


| 177920306 |


+-----------+


1 row in set (5.35 sec)



下面是我的测试结果


mysql>set local innodb_parallel_read_threads = 1;


执行成功,耗时:8 ms.


mysql>select count(*) from PARALLELTEST;


+--------------------+


| count(*) |


+--------------------+


| 9175040 |


+--------------------+


返回行数:[1],耗时:2275 ms.


mysql>select count(*) from PARALLELTEST;


+--------------------+


| count(*) |


+--------------------+


| 9175040 |


+--------------------+


返回行数:[1],耗时:2316 ms.


mysql>select count(*) from PARALLELTEST;


+--------------------+


| count(*) |


+--------------------+


| 9175040 |


+--------------------+


返回行数:[1],耗时:2191 ms.


mysql>select count(*) from PARALLELTEST;


+--------------------+


| count(*) |


+--------------------+


| 9175040 |


+--------------------+


返回行数:[1],耗时:2196 ms.


mysql>set local innodb_parallel_read_threads = 16;


执行成功,耗时:8 ms.


mysql>select count(*) from PARALLELTEST;


+--------------------+


| count(*) |


+--------------------+


| 9175040 |


+--------------------+


返回行数:[1],耗时:594 ms.


mysql>select count(*) from PARALLELTEST;


+--------------------+


| count(*) |


+--------------------+


| 9175040 |


+--------------------+


返回行数:[1],耗时:557 ms.


mysql>select count(*) from PARALLELTEST;


+--------------------+


| count(*) |


+--------------------+


| 9175040 |


+--------------------+


返回行数:[1],耗时:570 ms.


mysql>select count(*) from PARALLELTEST;


+--------------------+


| count(*) |


+--------------------+


| 9175040 |


+--------------------+


返回行数:[1],耗时:594 ms.


mysql>select count(*) from PARALLELTEST;


+--------------------+


| count(*) |


+--------------------+


| 9175040 |


+--------------------+


返回行数:[1],耗时:582 ms.


mysql>set local innodb_parallel_read_threads=32;


执行成功,耗时:9 ms.


mysql>select count(*) from PARALLELTEST;


+--------------------+


| count(*) |


+--------------------+


| 9175040 |


+--------------------+


返回行数:[1],耗时:265 ms.


mysql>select count(*) from PARALLELTEST;


+--------------------+


| count(*) |


+--------------------+


| 9175040 |


+--------------------+


返回行数:[1],耗时:251 ms.


mysql>set local innodb_parallel_read_threads=64;


执行成功,耗时:9 ms.


mysql>select count(*) from PARALLELTEST;


+--------------------+


| count(*) |


+--------------------+


| 9175040 |


+--------------------+


返回行数:[1],耗时:340 ms.


mysql>select count(*) from PARALLELTEST;


+--------------------+


| count(*) |


+--------------------+


| 9175040 |


+--------------------+


返回行数:[1],耗时:363 ms.


mysql>select count(*) from PARALLELTEST;


+--------------------+


| count(*) |


+--------------------+


| 9175040 |


+--------------------+


返回行数:[1],耗时:306 ms.


mysql>set local innodb_parallel_read_threads=32;


执行成功,耗时:9 ms.


mysql>select count(*) from PARALLELTEST;


+--------------------+


| count(*) |


+--------------------+


| 9175040 |


+--------------------+


返回行数:[1],耗时:276 ms.

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2026-4-17 23:42 , Processed in 0.215835 second(s), 21 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表