ถ้าอยากให้ คิวรี่ดังด้านล่าง ทำงานได้เร็วขึ้น ควรปรับแก้ส่วนไหนครับ
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 (153858,153859,153860,153861
,153862,153863,153864,153865,153866,153867,153868,153869
,153870,153871,153872,153873,153874,153875,153876,153877
,153878,153879,153880,153881,153882,153883,153884,153885
,153886,153887,153888,153889,153890,153891,153892,153893
,153894,153895,153896,153897,153898,153899,153900,153901
,153902,153903,153904,153905,153906,153907,153908,153909
,153910,153911,153912,153913,153914,153915,153916,153917
,153918,153919,153920,153921,153922,153923,153924,153925
,153926,153927,153928,153929,153930,153931,153932,153933
,153934,153935,153936,153937,153938,153939,153940,153941
,153942,153943,153944,153945,153946,153947,153948,153949
,153950,153951,153952,153953,153954,153955,153956,153957
,153958,153959,153960,153961,153962,153963,153964,153965
,153966,153967,153968,153969,153970,153971,153972,153973
,153974,153975,153976,153977,153978,153979,153980,153981
,153982,153983,153984,153985,153986,153987,153989,153990
,153991,153992,153993,153994,153995,153996,153997,153998
,153999,154000,154001,154002,154003,154004,154005,154007
,154008,154009,154010,154011,154012,154013,154014,154015
,154016,154017,154018,154019,154020,154021,154022,154023
,154024,154025,154026,154027,154028,154029,154030,154031
,154032,154033,154034,154035,154036,154037)
group by h.hn, pt.pname,pt.fname,pt.lname