QUERY PLAN
Aggregate (cost=381.66..381.67 rows=1 width=32)
-> Hash Join (cost=310.49..378.01 rows=1459 width=6)
Hash Cond: (tbl_purchase_contract_invoices.id = pci.id)
-> Seq Scan on tbl_purchase_contract_invoices (cost=0.00..60.75 rows=2575 width=10)
-> Hash (cost=292.26..292.26 rows=1459 width=4)
-> HashAggregate (cost=263.08..277.67 rows=1459 width=4)
Group Key: pci.id
-> Hash Right Join (cost=143.06..258.79 rows=1714 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=124.82..124.82 rows=1459 width=4)
-> Hash Right Join (cost=85.42..124.82 rows=1459 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=67.19..67.19 rows=1459 width=12)
-> Seq Scan on tbl_purchase_contract_invoices pci (cost=0.00..67.19 rows=1459 width=12)
Filter: ((from_date >= '2024-08-01'::date) OR (NOT is_draft))