MySQL Error: The timeout period elapsed prior to completion of the operation or the server is not responding

Last Reply one month ago By dharmendr

Posted one month ago

hi there.

I hope all u well in this situtation.

I have an issue regarding mysql execution i have a web forms regarding reporting from database.

consider following query

(SELECT lt.lab_test_name,SUM(case when left(o.gender,2)='iq' then 1 else 0 END) as Male,SUM(case when left(o.gender,2)='ef' then 1 else 0 end) as Female,
SUM(case when left(o.gender,2)='vU' then 1 else 0 end) as Others,cast(IFNULL(Sum(pl.fee),'0.00') as char)totalAmount  
FROM tbl_opd o INNER JOIN  tbl_patient_labtest pl ON o.opdno = pl.opdno LEFT JOIN tbl_lab_test lt ON pl.test_id = lt.id 
WHERE DATE_FORMAT(o.opd_date,'%Y-%m-%d') BETWEEN @fd AND @ed AND o.dept = 'LAB' AND pl.flag = 'N'  AND o.isCancelled=@iscancelled 
GROUP BY pl.test_id ORDER BY lt.lab_test_name)  UNION ALL (SELECT lt.lab_test_name,SUM(case when left(o.gender,2)='iq' then 1 else 0 END) as Male,
SUM(case when left(o.gender,2)='ef' then 1 else 0 end) as Female,SUM(case when left(o.gender,2)='vU' then 1 else 0 end) as Others,
cast(IFNULL(Sum(pl.fee),'0.00') as char)totalAmount  FROM tbl_opd o INNER JOIN  tbl_patient_labtest pl ON o.opdno = pl.opdno 
LEFT JOIN tbl_lab_test lt ON pl.test_id = lt.id WHERE DATE_FORMAT(o.opd_date,'%Y-%m-%d') BETWEEN @fd AND @ed AND o.dept = 'XRY' AND pl.flag = 'Y' AND o.isCancelled=@iscancelled  
GROUP BY pl.test_id ORDER BY lt.lab_test_name)

most of the time query executes well but sometime it shows following exeception

Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.

what should i do so that query executes well every time.

thanks in advance 

stay home stay safe.

You are viewing reply posted by: dharmendr one month ago.