记一个离谱的MySQL语句的性能问题
故障现象
-- 注:本文的SQL都进行了脱敏处理,但是绝对不影响理解
UPDATE production_embedding_map
SET deleted = true
WHERE production_id IN (SELECT production_id FROM t_delete_production_ids);故障重现
create temporary table t_delete_production_ids
(
production_id INT UNSIGNED
);
insert into t_delete_production_ids (production_id)
select production_id
from (select distinct production_id
from production) eids
order by RAND()
limit 3000;分析与修复
id
select_type
table
partitions
type
possible_keys
key
key_len
ref
rows
filtered
Extra
id
select_type
table
partitions
type
possible_keys
key
key_len
ref
rows
filtered
Extra
id
select_type
table
partitions
type
possible_keys
key
key_len
ref
rows
filtered
Extra
所以MySQL到底更新了什么
这个故事告诉我们什么
最后更新于