QUERY PLAN
Aggregate (cost=603.10..603.11 rows=1 width=8)
-> Group (cost=603.06..603.07 rows=2 width=4)
Group Key: c.id
-> Sort (cost=603.06..603.07 rows=2 width=4)
Sort Key: c.id
-> Hash Join (cost=405.42..603.05 rows=2 width=4)
Hash Cond: (c.client_id = cl.id)
-> Hash Right Join (cost=310.67..508.19 rows=44 width=8)
Hash Cond: (ca.case_id = c.id)
-> Seq Scan on tbl_case_assignments ca (cost=0.00..174.95 rows=8595 width=4)
-> Hash (cost=310.12..310.12 rows=44 width=8)
-> Seq Scan on tbl_cases c (cost=0.00..310.12 rows=44 width=8)
Filter: (case_status = ANY ('{1,2,3,4}'::integer[]))
-> Hash (cost=93.88..93.88 rows=70 width=4)
-> Bitmap Heap Scan on tbl_clients cl (cost=4.82..93.88 rows=70 width=4)
Recheck Cond: (sales_rep = 1001)
-> Bitmap Index Scan on tbl_clients_sales_rep_idx (cost=0.00..4.80 rows=70 width=0)
Index Cond: (sales_rep = 1001)