QUERY PLAN
Aggregate (cost=226.42..226.43 rows=1 width=32)
-> Nested Loop (cost=218.38..226.42 rows=1 width=6)
-> Group (cost=218.10..218.10 rows=1 width=4)
Group Key: pci.id
-> Sort (cost=218.10..218.10 rows=1 width=4)
Sort Key: pci.id
-> Hash Right Join (cost=119.48..218.09 rows=1 width=4)
Hash Cond: (pcpp.purchase_invoice_id = pci.id)
-> Seq Scan on tbl_purchase_invoice_products pcpp (cost=0.00..87.25 rows=3025 width=4)
-> Hash (cost=119.47..119.47 rows=1 width=4)
-> Hash Right Join (cost=80.08..119.47 rows=1 width=4)
Hash Cond: (pip.purchase_invoice_id = pci.id)
-> Seq Scan on tbl_purchase_invoice_projects pip (cost=0.00..33.69 rows=2169 width=8)
-> Hash (cost=80.06..80.06 rows=1 width=12)
-> Seq Scan on tbl_purchase_contract_invoices pci (cost=0.00..80.06 rows=1 width=12)
Filter: (is_verify AND (verify_at >= '2026-05-01'::date) AND (verify_at <= '2026-05-31'::date) AND ((from_date >= '2024-08-01'::date) OR (NOT is_draft)))
-> Index Scan using tbl_purchase_contract_invoices_pkey on tbl_purchase_contract_invoices (cost=0.28..8.30 rows=1 width=10)
Index Cond: (id = pci.id)