มันจะมีคำสั่งนึงนะครับที่ทำให้เกิดการทำงานที่ช้ามากของข้อมูลลองใช้ sql show tract window แล้วเจอครับ
Date Time Type Exec Time SQL Text
52-03-04 18:52:37.015 SQL 85,875 select h.lab_order_number,h.lis_order_no,v.pcode,a.pcode as apcode, h.lab_receive_number,h.vn,h.hn,h.order_date ,h.order_time, h.lock_result,h.receive_time as service13,h.report_time as service14 ,h.confirm_report,d.name as doctor_name, concat(pt.pname,pt.fname,' ',pt.lname) as ptname , h.form_name ,v.rcpt_money as opaid,a.rcpt_money as ipaid , v.age_y as vage_y,a.age_y as aage_y ,h.department,concat(w.name,' - ',adm.bedno) as ward_name , k.department as department_name ,sp.name as spclty_name,lp.lab_perform_status_name,h.anonymous_request from lab_head h left outer join patient pt on pt.hn=h.hn left outer join doctor d on d.code=h.doctor_code left outer join vn_stat v on v.vn=h.vn left outer join spclty sp on sp.spclty = h.spclty left outer join an_stat a on a.an=h.vn left outer join kskdepartment k on k.depcode = h.order_department left outer join ward w on w.ward = a.ward left outer join iptadm adm on adm.an = a.an left outer join lab_perform_status lp on lp.lab_perform_status_id = h.lab_perform_status_id where h.lab_order_number in (47863,47864,47865,47866,47867,47868,47869,47870,47871,47872,47873,47874,47875,47876,47877,47878,47879,47880,47881,47882,47883,47884,47885,47886,47887,47888,47889,47890,47891,47892,47893,47894,47895,47896,47897,47898,47900,47901,47902,47903,47904,47905,47906,47907,47908,47909,47910,47911,47912,47913,47914,47915,47916,47917,47918,47920,47923,47924,47925,47927,47928,47929,47931) order by h.order_date,h.order_time
Date Time Type Exec Time SQL Text
52-03-04 18:53:15.406 SQL 38,359 select h.hn, concat(pt.pname,pt.fname,' ',pt.lname) as ptname , count(h.lab_order_number) as order_count from lab_head h left outer join patient pt on pt.hn=h.hn left outer join doctor d on d.code=h.doctor_code left outer join vn_stat v on v.vn=h.vn left outer join an_stat a on a.an=h.vn left outer join kskdepartment k on k.depcode = h.order_department left outer join ward w on w.ward = a.ward left outer join iptadm adm on adm.an = a.an left outer join lab_perform_status lp on lp.lab_perform_status_id = h.lab_perform_status_id where h.lab_order_number in (47863,47864,47865,47866,47867,47868,47869,47870,47871,47872,47873,47874,47875,47876,47877,47878,47879,47880,47881,47882,47883,47884,47885,47886,47887,47888,47889,47890,47891,47892,47893,47894,47895,47896,47897,47898,47900,47901,47902,47903,47904,47905,47906,47907,47908,47909,47910,47911,47912,47913,47914,47915,47916,47917,47918,47920,47923,47924,47925,47927,47928,47929,47931) group by h.hn, pt.pname,pt.fname,pt.lname
2 คำสั่งนี้ครับ