次のクエリを mssql から mysql に移行しました。
SELECT employee.ecode, fname, mname, lname
FROM employee
WHERE employee.cmp_dol IS NULL
AND employee.ecode IN
(SELECT leave_log.ecode
FROM leave_log
WHERE (l_acc_code = 11 OR l_acc_code = 21 OR l_acc_code = 31 OR l_acc_code = 41 OR l_acc_code = 51 OR l_acc_code = 61 )
GROUP BY leave_log.ecode, l_date, l_acc_code
HAVING SUM(l_value) <> 0)
AND employee.ecode IN ((SELECT ecode
FROM emp_supervisor
WHERE sup_id = @ecode
AND emp_sup_dol IS NULL)
UNION
(SELECT ecode
FROM emp_project
WHERE proj_emp_dol IS NULL
AND pid IN (SELECT pid
FROM proj_supervisor
WHERE proj_sup_dol IS NULL
AND sup_id =@ecode
AND pid IN (SELECT pid
FROM projects
WHERE p_end_date IS NULL
AND leave_flag=1))))
ORDER BY fname
クエリの IN ステートメントでは、無限の時間がかかります。しかし、私が存在するものに置き換えると、別の出力が得られます。
どんな助けでも大歓迎です。