I am running a very long query described below. It fetches the next needed action for each account on an automation system.
SELECT Account.id, (IFNULL(**Should send message query**, IFNULL(**Should check inbox**, NULL))) as nextTask FROM Account
In reality the string of IFNULL's is around 10, each is quite a complicated subquery.
I want to know if MySQL will compute the values for following IFNULL expression if the first is satisfied. That is, if an account should send a message, it shouldn't bother computing the subquery for Should check inbox
Is this how MySQL works?
What's the difference between this and CASE WHEN's
CASE WHEN **Should send message** THEN **Should send message** WHEN **Should check inbox** THEN **Should check inbox** END
I just want to get the CPU usage down for this query.