I have a number of calls which are similar. Below is one:
$STH = $DBH->prepare("
SELECT t.mobile, t.unum
FROM teacher t
LEFT JOIN s_group_member m ON m.unum = t.unum
LEFT JOIN s_group g ON g.gnum = m.gnum
WHERE m.gnum = :g AND g.unum = :u
AND t.unum NOT IN (SELECT unum FROM t_unav WHERE unav_date = :d)");
It gets data from the teacher
table where (1) the teacher is a member of a specified group, (2) the group belongs to the user, and (3) the teacher is not unavailable.
My question concerns which will prove quickest:
- Make the sub-select call each time.
- Cache the sub-select into an array, and then use IN($array) like in this post.
- Create a temporary table.
A similar call is made a fair few times - maybe 20-30...
Thanks.