a — это индексированное значение столбца_1 в таблице test_table. 1 — это первичный ключ в test_table. Возникла проблема: когда я обновляю определенную строку в test_table исходным значением «a» столбца_1, кажется, что она запрашивает LOCK DATA.
Код: Выделить всё
'a', 1. Однако я получил блокировку строки только для этой конкретной строки 1Моя структура таблицы:
table1: test_table
table2: test_table2
Код: Выделить всё
create table test_table
(
id int not null
primary key,
column_1 varchar(100) null,
column_4 int null
);
create index `1_4_index`
on test_table (column_1, column_4);
create index id_index
on test_table (column_1);
create table test_table2
(
id int not null
primary key,
column_3 varchar(100) null,
column_5 varchar(100) null
);
table1 data:
id column1 column_4
1 a NULL
2 c NULL
3 a NULL
4 c NULL
table2 data:
id column3 column_5
1 "" NULL
2 "" NULL
3 "" NULL
4 "" NULL
Код: Выделить всё
begin;
select * from test_table INNER join test_table2 t on test_table.id = t.id where test_table.id=1 for update
update test_table set column_1='x' where id=1
commit;
Код: Выделить всё
begin;
use commit_queue
select * from test_table inner join test_table2 on test_table.id = test_table2.id where test_table.column_1 = 'a' for update
commit;
Я думаю, это может быть вызвано индексом, поскольку LOCK_DATA транзакции 1 равен 1, а транзакция 2 снова заблокирует эту строку с помощью LOCK_DATA 'a',1
Подробнее здесь: https://stackoverflow.com/questions/793 ... om-perform
Мобильная версия