QUERY PLAN
Aggregate (cost=559.17..559.18 rows=1 width=8)
-> Group (cost=559.15..559.16 rows=1 width=4)
Group Key: c.id
-> Sort (cost=559.15..559.16 rows=1 width=4)
Sort Key: c.id
-> Nested Loop (cost=287.34..559.14 rows=1 width=4)
-> Hash Right Join (cost=287.06..470.77 rows=14 width=8)
Hash Cond: (ca.case_id = c.id)
-> Seq Scan on tbl_case_assignments ca (cost=0.00..162.76 rows=7976 width=4)
-> Hash (cost=286.89..286.89 rows=14 width=8)
-> Seq Scan on tbl_cases c (cost=0.00..286.89 rows=14 width=8)
Filter: (case_status = ANY ('{1,2,3,4}'::integer[]))
-> Index Scan using tbl_clients_pkey on tbl_clients cl (cost=0.28..6.30 rows=1 width=4)
Index Cond: (id = c.client_id)
Filter: (sales_rep = 1001)