QUERY PLAN
Aggregate (cost=666.60..666.61 rows=1 width=32)
-> Hash Join (cost=429.19..666.60 rows=1 width=8)
Hash Cond: (ca.case_id = c.id)
-> Seq Scan on tbl_case_assignments ca (cost=0.00..222.58 rows=5644 width=12)
Filter: (engineer_id = ANY ('{1017,5085,5248,1015,1022,1023}'::integer[]))
-> Hash (cost=429.18..429.18 rows=1 width=4)
-> Subquery Scan on c (cost=429.16..429.18 rows=1 width=4)
-> Group (cost=429.16..429.17 rows=1 width=285)
Group Key: c_1.id
-> Sort (cost=429.16..429.16 rows=1 width=4)
Sort Key: c_1.id
-> Hash Right Join (cost=306.72..429.15 rows=1 width=4)
Hash Cond: (cs.case_id = c_1.id)
-> Seq Scan on tbl_case_services cs (cost=0.00..104.66 rows=6766 width=4)
-> Hash (cost=306.71..306.71 rows=1 width=4)
-> Seq Scan on tbl_cases c_1 (cost=0.00..306.71 rows=1 width=4)
Filter: ((deduct_points_from IS NULL) AND (closed_at >= '2025-08-01 00:00:00+08'::timestamp with time zone) AND (closed_at <= '2025-08-31 23:59:59+08'::timestamp with time zone) AND (case_type = 1))