[英]can someone help me on this? [closed]
我想优化下面的查询,目前,它用于全表扫描。 NOT IN 运算符是否有可能重写?
DELETE
FROM `r_so`
WHERE `created_on` < '2022-03-09 00:00:00'
AND `so_id` NOT IN (select distinct so_id
from r_rating
) LIMIT 1000
*************************** 1. row ***************************
id: 1
select_type: DELETE
table: review_so
partitions: NULL
type: range
possible_keys: created_on_idx
key: created_on_idx
key_len: 5
ref: const
rows: 132979575
filtered: 100.00
Extra: Using where
*************************** 2. row ***************************
id: 2
select_type: DEPENDENT SUBQUERY
table: rev_rating
partitions: NULL
type: unique_subquery
possible_keys: UK_r_rating_so_id
key: UK_r_rating_so_id
key_len: 36
ref: func
rows: 1
filtered: 100.00
Extra: Using index
有没有可能重写这个查询?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.