QUERY PLAN
Aggregate (cost=380.97..380.98 rows=1 width=8)
-> Hash Join (cost=309.88..377.33 rows=1453 width=0)
Hash Cond: (tbl_purchase_contract_invoices.id = pci.id)
-> Seq Scan on tbl_purchase_contract_invoices (cost=0.00..60.70 rows=2570 width=4)
-> Hash (cost=291.71..291.71 rows=1453 width=4)
-> HashAggregate (cost=262.65..277.18 rows=1453 width=4)
Group Key: pci.id
-> Hash Right Join (cost=142.83..258.39 rows=1706 width=4)
Hash Cond: (pcpp.purchase_invoice_id = pci.id)
-> Seq Scan on tbl_purchase_invoice_products pcpp (cost=0.00..87.18 rows=3018 width=4)
-> Hash (cost=124.67..124.67 rows=1453 width=4)
-> Hash Right Join (cost=85.29..124.67 rows=1453 width=4)
Hash Cond: (pip.purchase_invoice_id = pci.id)
-> Seq Scan on tbl_purchase_invoice_projects pip (cost=0.00..33.68 rows=2168 width=8)
-> Hash (cost=67.12..67.12 rows=1453 width=12)
-> Seq Scan on tbl_purchase_contract_invoices pci (cost=0.00..67.12 rows=1453 width=12)
Filter: ((from_date >= '2024-08-01'::date) OR (NOT is_draft))