QUERY PLAN
Aggregate (cost=405.31..405.32 rows=1 width=8)
-> Sort (cost=405.29..405.30 rows=1 width=285)
Sort Key: c.updated_at DESC
-> Group (cost=405.27..405.28 rows=1 width=285)
Group Key: c.id
-> Sort (cost=405.27..405.28 rows=1 width=12)
Sort Key: c.id
-> Nested Loop (cost=0.29..405.26 rows=1 width=12)
-> Seq Scan on tbl_case_assignments ca (cost=0.00..210.26 rows=29 width=4)
Filter: ((assignment_status = ANY ('{1,2}'::integer[])) AND (engineer_id = 1001))
-> Index Scan using tbl_cases_pkey on tbl_cases c (cost=0.29..6.65 rows=1 width=12)
Index Cond: (id = ca.case_id)
Filter: (case_status = ANY ('{1,2,3}'::integer[]))