QUERY PLAN
Aggregate (cost=718.28..718.29 rows=1 width=32)
-> Hash Join (cost=449.71..718.22 rows=23 width=8)
Hash Cond: (ca.case_id = c.id)
-> Seq Scan on tbl_case_assignments ca (cost=0.00..251.68 rows=6409 width=12)
Filter: (engineer_id = ANY ('{1017,5085,1001,5248,1015,1022,5296,1023}'::integer[]))
-> Hash (cost=449.34..449.34 rows=29 width=4)
-> Subquery Scan on c (cost=448.91..449.34 rows=29 width=4)
-> Group (cost=448.91..449.05 rows=29 width=285)
Group Key: c_1.id
-> Sort (cost=448.91..448.98 rows=29 width=4)
Sort Key: c_1.id
-> Hash Right Join (cost=319.41..448.21 rows=29 width=4)
Hash Cond: (cs.case_id = c_1.id)
-> Seq Scan on tbl_case_services cs (cost=0.00..110.12 rows=7112 width=4)
-> Hash (cost=319.04..319.04 rows=29 width=4)
-> Seq Scan on tbl_cases c_1 (cost=0.00..319.04 rows=29 width=4)
Filter: ((deduct_points_from IS NULL) AND (closed_at >= '2025-01-01 00:00:00+08'::timestamp with time zone) AND (closed_at <= '2025-12-31 23:59:59+08'::timestamp with time zone) AND (case_type = 1))