我的查询看起来像
SELECT to_number FROM sent_texts
WHERE to_number NOT IN(SELECT mobile FROM action_6_members);
Run Code Online (Sandbox Code Playgroud)
查询完成后,WHERE应用于结果集.
如果包含子查询,效果是什么(改进/降级)
WHERE mobile = to_number
Run Code Online (Sandbox Code Playgroud)
在查询期间将HAVING应用于结果集.
如果包含子查询,效果是什么(改进/降级)
HAVING mobile = to_number
Run Code Online (Sandbox Code Playgroud)
使用原始查询有哪些优点/缺点?
所以我将用原始查询的解释来更新它.
这个查询导致我的服务器使用100%的cpu.
也许有人可以说出原因,以及如何解决这个问题?
id select_type table type possible_keys key key_len ref rows Extra 2 DEPENDENT SUBQUERY action_6_members index mobile 42 179218 Using where; Using index 1 PRIMARY sent_txts index to_number 123 256066 Using where; Using index
这是基于联接的解释(经过一些更优化)
id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE sent_txts index to_number 78 256066 Using index 1 SIMPLE action_6_members index mobile 27 179218 Using where; Using index; Not exists