QUERY PLAN
Limit (cost=244.92..244.97 rows=20 width=211)
-> Sort (cost=244.92..245.12 rows=80 width=211)
Sort Key: c.signed_at DESC, c.created_at DESC
-> Group (cost=242.19..242.79 rows=80 width=211)
Group Key: c.id
-> Sort (cost=242.19..242.39 rows=80 width=179)
Sort Key: c.id
-> Hash Left Join (cost=159.03..239.66 rows=80 width=179)
Hash Cond: (client.sales_rep = sgr.sales_id)
-> Nested Loop Left Join (cost=156.88..236.80 rows=80 width=183)
-> Hash Right Join (cost=156.61..198.32 rows=80 width=183)
Hash Cond: (pcr.contract_id = c.id)
-> Seq Scan on tbl_purchase_client_rels pcr (cost=0.00..33.07 rows=2107 width=8)
-> Hash (cost=155.61..155.61 rows=80 width=179)
-> Hash Right Join (cost=135.76..155.61 rows=80 width=179)
Hash Cond: (pcp1.purchase_contract_id = c.id)
-> Seq Scan on tbl_purchase_contract_contact_points pcp1 (cost=0.00..17.80 rows=780 width=8)
-> Hash (cost=134.76..134.76 rows=80 width=179)
-> Seq Scan on tbl_purchase_contracts c (cost=0.00..134.76 rows=80 width=179)
Filter: ((NOT is_draft) AND (NOT is_verify) AND (signed_at >= '2026-01-01'::date) AND (signed_at <= '2026-12-31'::date) AND (cost_type = 1))
-> Index Scan using tbl_clients_pkey on tbl_clients client (cost=0.28..0.48 rows=1 width=8)
Index Cond: (pcr.client_id = id)
-> Hash (cost=1.51..1.51 rows=51 width=4)
-> Seq Scan on tbl_sales_group_relationships sgr (cost=0.00..1.51 rows=51 width=4)