QUERY PLAN
Aggregate (cost=168.68..168.69 rows=1 width=32)
-> Nested Loop (cost=74.57..168.63 rows=22 width=6)
-> Hash Join (cost=74.29..118.63 rows=72 width=10)
Hash Cond: (scp.contract_id = c.id)
-> Seq Scan on tbl_sales_contract_payments scp (cost=0.00..44.16 rows=72 width=10)
Filter: ((collected_date >= '2025-01-01'::date) AND (collected_date < '2026-01-01 00:00:00'::timestamp without time zone))
-> Hash (cost=55.24..55.24 rows=1524 width=8)
-> Seq Scan on tbl_sales_contracts c (cost=0.00..55.24 rows=1524 width=8)
-> Index Scan using tbl_projects_pkey on tbl_projects p (cost=0.28..0.69 rows=1 width=4)
Index Cond: (id = c.from_project)
Filter: ((project_status = 3) AND (created_by = ANY ('{1001,1004,1005,1013,5087,5295,5300,5311,5329,5332,5420}'::integer[])))