数据库名称: Aurora mySQL
数据库版本:
内容/问题描述:
我有一个表格 Schema
CREATE TABLE `credit` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`company_id` int(10) unsigned NOT NULL,
`agent_id` int(10) unsigned NOT NULL,
`balance_before` decimal(15,5) NOT NULL,
`amount` decimal(15,5) NOT NULL,
`balance_after` decimal(15,5) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `agent_amount` (`agent_id`,`amount`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
我在做交易的时候下了
SELECT * FROM credit Where agent_id = "{agent_id}" FOR UPDATE
UPDATE credit set amount = "amount" WHERE agent_id = "{agent_id}"
在高并发的情境下,很容易发生 DeadLock
请问如果我的索引是用复合索引,是否不会是行锁而是表锁
谢谢回复