I have a query that looks something like
SELECT to_number FROM sent_texts
WHERE to_number NOT IN(SELECT mobile FROM action_6_members);
A WHERE is applied to the result set after the query is complete.
What would the effect be (improve/degrade) if the sub query contained
WHERE mobile = to_number
A HAVING is applied to the result set during the query.
What would the effect be (improve/degrade) if the sub query contained
HAVING mobile = to_number
What are the pros/cons of just using the original query?
Update
It seems my initial thoughts were wrong, thanks to Bill Karwin's answer.
So Im going to update this with the explain of the original query.
This query is causing me my server to use 100% of the cpu.
Maybe someone can say why, and how to fix it?
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
This is the explain based off the join(after some more optimization)
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