QUERY PLAN
GroupAggregate (cost=224.56..224.59 rows=1 width=44)
Group Key: sub.verify
-> Sort (cost=224.56..224.57 rows=1 width=14)
Sort Key: sub.verify
-> Subquery Scan on sub (cost=224.53..224.55 rows=1 width=14)
-> Group (cost=224.53..224.54 rows=1 width=14)
Group Key: pci.id
-> Sort (cost=224.53..224.54 rows=1 width=11)
Sort Key: pci.id
-> Hash Right Join (cost=125.92..224.52 rows=1 width=11)
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=125.91..125.91 rows=1 width=11)
-> Hash Right Join (cost=86.51..125.91 rows=1 width=11)
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=86.50..86.50 rows=1 width=19)
-> Seq Scan on tbl_purchase_contract_invoices pci (cost=0.00..86.50 rows=1 width=19)
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)) AND (invoice_type <> '-1'::smallint))