MySQL:关于RR模式下insert..select sending data状态说明

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
云数据库 RDS PostgreSQL,高可用系列 2核4GB
简介: MySQL:关于RR模式下insert..select sending data状态说明

、案例由来

最近看到有人在问如下:

其中的sending data是什么意思。隔离级别为RR,语句为insert..select。

二、关于sending data

以前就说过这个问题,实际上sending data可能包含如下:

  • Innodb 层数据的定位返回给MySQL 层
  • Innodb 层数据的查询返回给MySQL 层
  • Innodb 层数据的修改(如果是insert..select)
  • Innodb 层加锁以及等待
  • 等待进入Innodb层(innodb_thread_concurrency参数)
  • MySQL 层发送数据给客户端

三、RR模式下对于insert..selcet 处于 sending data的原因总结

  • RR模式下insert..select的select表会上S行锁,如果这行处于X锁则会出现 sending data状态
  • insert..selcet中insert记录如果处于堵塞(唯一性检查)状态会处于 sending data状态
  • 整个过程如果需要操作的数据量较大,处于sending data状态。

四、每行数据处理方式

929 T@4: | | | | | | THD::enter_stage: 'Sending data' /cdh/mysqldebug/percona-server-5.7.29-32/sql/sql_executor.cc:202
    930 T@4: | | | | | | >PROFILING::status_change
    931 T@4: | | | | | | <PROFILING::status_change 391
    932 T@4: | | | | | | info: Sending data
    933 T@4: | | | | | | >do_select
    934 T@4: | | | | | | | >sub_select
    935 T@4: | | | | | | | | >init_read_record
    936 T@4: | | | | | | | | | info: using rr_sequential
    937 T@4: | | | | | | | | | >ha_rnd_init
    938 T@4: | | | | | | | | | | >change_active_index
    939 T@4: | | | | | | | | | | | >innobase_get_index
    940 T@4: | | | | | | | | | | | <innobase_get_index 10117
    941 T@4: | | | | | | | | | | <change_active_index 10241
    942 T@4: | | | | | | | | | <ha_rnd_init 3111
    943 T@4: | | | | | | | | | >innobase_trx_init
    944 T@4: | | | | | | | | | <innobase_trx_init 3109
    945 T@4: | | | | | | | | <init_read_record 349
    946 T@4: | | | | | | | | >handler::ha_rnd_next
    947 T@4: | | | | | | | | | >rnd_next
    948 T@4: | | | | | | | | | | >index_first
    949 T@4: | | | | | | | | | | | >index_read
    950 T@4: | | | | | | | | | | | | >row_search_mvcc
    951 T@4: | | | | | | | | | | | | | >row_sel_store_mysql_rec
    952 T@4: | | | | | | | | | | | | | | >row_sel_store_mysql_field_func
    953 T@4: | | | | | | | | | | | | | | <row_sel_store_mysql_field_func 3275
    954 T@4: | | | | | | | | | | | | | | >row_sel_store_mysql_field_func
    955 T@4: | | | | | | | | | | | | | | <row_sel_store_mysql_field_func 3275
    956 T@4: | | | | | | | | | | | | | <row_sel_store_mysql_rec 3465
    957 T@4: | | | | | | | | | | | | <row_search_mvcc 6574
    958 T@4: | | | | | | | | | | | <index_read 10042
    959 T@4: | | | | | | | | | | <index_first 10430
    960 T@4: | | | | | | | | | <rnd_next 10531
    961 T@4: | | | | | | | | <handler::ha_rnd_next 3172
    962 T@4: | | | | | | | | >evaluate_join_record
    963 T@4: | | | | | | | | | enter: join: 0x7ffef8019970 join_tab index: 0 table: testlock cond: 0x0
    964 T@4: | | | | | | | | | counts: evaluate_join_record join->examined_rows++: 1
    965 T@4: | | | | | | | | | >end_send
    966 T@4: | | | | | | | | | | >Query_result_insert::send_data
    967 T@4: | | | | | | | | | | | >fill_record
    968 T@4: | | | | | | | | | | | | >Item_field::save_in_field_inner
    969 T@4: | | | | | | | | | | | | <Item_field::save_in_field_inner 6720
    970 T@4: | | | | | | | | | | | | >Item_field::save_in_field_inner
    971 T@4: | | | | | | | | | | | | <Item_field::save_in_field_inner 6720
    972 T@4: | | | | | | | | | | | <fill_record 9801
    973 T@4: | | | | | | | | | | | >write_record
    974 T@4: | | | | | | | | | | | | >init_alloc_root
    975 T@4: | | | | | | | | | | | | | enter: root: 0x7fffe8e48c20
    976 T@4: | | | | | | | | | | | | <init_alloc_root 100
    977 T@4: | | | | | | | | | | | | >COPY_INFO::set_function_defaults
    978 T@4: | | | | | | | | | | | | <COPY_INFO::set_function_defaults 135
    979 T@4: | | | | | | | | | | | | >handler::ha_write_row
    980 T@4: | | | | | | | | | | | | | >ha_innobase::write_row
    981 T@4: | | | | | | | | | | | | | | >row_ins
    982 T@4: | | | | | | | | | | | | | | | row_ins: table: test/testbb
    983 T@4: | | | | | | | | | | | | | | | >row_ins_index_entry_step
    984 T@4: | | | | | | | | | | | | | | | | >row_ins_clust_index_entry
    985 T@4: | | | | | | | | | | | | | | | | | >row_ins_clust_index_entry_low
    986 T@4: | | | | | | | | | | | | | | | | | | >btr_cur_search_to_nth_level
    987 T@4: | | | | | | | | | | | | | | | | | | <btr_cur_search_to_nth_level 2092
    988 T@4: | | | | | | | | | | | | | | | | | | >thd_report_row_lock_wait
    989 T@4: | | | | | | | | | | | | | | | | | | <thd_report_row_lock_wait 4280
    990 T@4: | | | | | | | | | | | | | | | | | <row_ins_clust_index_entry_low 2692
    991 T@4: | | | | | | | | | | | | | | | | <row_ins_clust_index_entry 3337
    992 T@4: | | | | | | | | | | | | | | | <row_ins_index_entry_step 3619
    993 T@4: | | | | | | | | | | | | | | <row_ins 3763
    994 T@4: | | | | | | | | | | | | | | >thd_mark_transaction_to_rollback
    995 T@4: | | | | | | | | | | | | | | <thd_mark_transaction_to_rollback 4147
    996 T@4: | | | | | | | | | | | | | <ha_innobase::write_row 8895
    997 T@4: | | | | | | | | | | | | <handler::ha_write_row 8565

及RR模式下insert select的逻辑大概为查询一行加锁(RC下没有加锁步骤)一行插入一行,直到所有行处理完成。整个过程处于'Sending data'状态下面。因此insert select和普通的insert操作有较大的区别。

关于sending data扩展阅读,参考我的一篇文章:

MySQL:sending data状态包含了什么

http://blog.itpub.net/7728585/viewspace-2215202/

全文完。

            </div>
相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。 &nbsp; 相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情:&nbsp;https://www.aliyun.com/product/rds/mysql&nbsp;
相关文章
|
Python
请你介绍一下 Python 中的多态性。
【2月更文挑战第16天】【2月更文挑战第47篇】
165 1
|
Linux Shell 调度
15.2 【Linux】仅执行一次的工作调度
15.2 【Linux】仅执行一次的工作调度
131 0
|
虚拟化 Windows
Windows Server 2016 中文版、英文版下载 (2025 年 6 月更新)
Windows Server 2016 中文版、英文版下载 (2025 年 6 月更新)
1352 0
|
运维 关系型数据库 MySQL
阿里 P7 到底是怎样的水平?
大家好,我是锋哥,今天分享我楼仔兄弟的一篇好文,希望对大家有帮助 ! 前几天二哥找我,问我阿里 P7 是怎样的水平,在面试中如何才能拿到阿里 P7 的职级。
|
弹性计算 大数据 测试技术
阿里服务器租用多少钱一年?阿里云服务器租用价格表(最新CPU/内存/带宽/磁盘收费标准)
阿里服务器租用多少钱一年?阿里云服务器租用价格表(最新CPU/内存/带宽/磁盘收费标准)。阿里云服务器的租用费用因实例类型、地域、配置等因素而有所不同,价格范围可以从几百元到几千元不等。2024年阿里云服务器租用费用价格表更新,云服务器ECS经济型e实例2核2G、3M固定带宽99元一年、ECS u1实例2核4G、5M固定带宽、80G ESSD Entry盘优惠价格199元一年,轻量应用服务器2核2G3M带宽轻量服务器一年61元、2核4G4M带宽轻量服务器一年165元12个月、2核4G服务器30元3个月,幻兽帕鲁4核16G和8核32G服务器配置,云服务器ECS可以选择经济型e实例、通用算力u1实
|
easyexcel Java Maven
springboot使用EasyExcel导入导出填充,解决导出乱码问题(web)
springboot使用EasyExcel导入导出填充,解决导出乱码问题(web)
1717 5
|
消息中间件 监控 算法
Kafka 常用工具脚本总结
Kafka 常用工具脚本总结
799 0
|
存储 云安全 安全
【探花交友】day02—完善个人信息(一)
【探花交友】day02—完善个人信息
1818 0
|
监控 数据挖掘
数据分析八大模型:人货场模型
之前分享了销售分析的基本做法,今天来分享一个销售分析最常用的模型:人货场模型。这是来源于传统零售业的经典分析模型,在电商环境里其实也能用。大家一起来看一下。 传送门:一文看懂:销售数据分析怎么做?
1511 0
数据分析八大模型:人货场模型
|
小程序
微信小程序生成二维码(含源码)
微信小程序生成二维码(含源码)
291 0