QUERY PLAN
GroupAggregate (cost=152.51..152.63 rows=6 width=36)
Group Key: client.sales_rep
-> Sort (cost=152.51..152.52 rows=6 width=10)
Sort Key: client.sales_rep
-> Nested Loop (cost=0.28..152.43 rows=6 width=10)
-> Seq Scan on tbl_sales_contracts contract (cost=0.00..76.98 rows=11 width=10)
Filter: ((NOT COALESCE(is_draft, false)) AND COALESCE(need_analysis, true) AND (signed_at >= '2026-01-01'::date) AND (signed_at <= '2026-12-31'::date))
-> Index Scan using tbl_clients_pkey on tbl_clients client (cost=0.28..6.86 rows=1 width=8)
Index Cond: (id = contract.client_id)
Filter: (sales_rep = ANY ('{5500,5499,5332,1001,5087,5467,5300,5311,5295,1013,5476,1004,1005,5449}'::integer[]))