环境:mysql5.7 ,隔离级别是读已提交,表记录数大约32万,更新语句更新了大约12万记录。 现象:update语句执行了大约18秒,执行过程中processlist里面发现这个表上的select查询等待waitting for table flush,执行过程中没有对表进行其他操作,更新结束后恢复正常 建表语句,更新语句,查询语句如下: 建表语句 CREATE TABLE `tb_reg_xxxx` ( `id` bigint(20) NOT NULL AUTO_INCREMENT , `mch_id` varchar(32) NOT NULL , `business_code` varchar(64) NOT NULL , `login_account` varchar(512) DEFAULT NULL , `sub_mch_id` varchar(32) DEFAULT NULL , `status` varchar(32) DEFAULT NULL , `business_type` varchar(32) DEFAULT NULL , `sign_status` varchar(32) DEFAULT NULL , `creator` varchar(32) DEFAULT NULL , `create_time` datetime DEFAULT CURRENT_TIMESTAMP , `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP , `contract_type` varchar(16) DEFAULT NULL , `pos_mch_id` varchar(32) DEFAULT NULL , `open_account_time` datetime DEFAULT NULL , `reseller_id` varchar(16) DEFAULT NULL , PRIMARY KEY (`id`), UNIQUE KEY `udx_reg_request_businesscode` (`mch_id`,`business_code`), KEY `udx_reg_request_ctime` (`create_time`), KEY `idx_reg_request_login_account` (`login_account`), KEY `udx_reg_request_utime` (`update_time`), KEY `udx_reg_request_otime` (`open_account_time`) USING BTREE, KEY `idx_regrequest_submchid` (`sub_mch_id`), KEY `idx_reg_req_status` (`status`,`update_time`), KEY `idx_reg_req_mch_resell` (`mch_id`,`reseller_id`,`creator`) ) ENGINE=InnoDB AUTO_INCREMENT=327821 DEFAULT CHARSET=utf8mb4 ; 更新语句 UPDATE tb_reg_xxxx SET sign_status='SIGNING' WHERE contract_type='E' AND sign_status='WAIT'; 查询语句类似 select * from ( select * from tb_reg_xxxx WHERE ( mch_id = '123456789' and business_type = 'RESELLER' ) order by create_time desc )row_ limit 0,10 |
qtiger
2023-7-21 10:21:53
| ||
qtiger
2023-7-21 10:23:49
| ||
yejr
2023-7-21 16:30:49
| ||
qtiger
2023-7-21 17:33:39
| ||
张旭峰
2023-7-23 15:42:45
| ||
qtiger
2023-8-2 11:15:53
| ||
qtiger
2023-8-2 13:01:39
| ||
合作电话:010-64087828
社区邮箱:greatsql@greatdb.com