QUERY PLAN
HashAggregate (cost=243.68..246.18 rows=200 width=44)
Group Key: CASE WHEN pci.is_verify THEN 1 ELSE 0 END
-> HashAggregate (cost=230.48..235.28 rows=480 width=14)
Group Key: pci.id
-> Hash Right Join (cost=124.93..229.07 rows=564 width=11)
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=118.93..118.93 rows=480 width=11)
-> Hash Right Join (cost=79.55..118.93 rows=480 width=11)
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=73.55..73.55 rows=480 width=19)
-> Seq Scan on tbl_purchase_contract_invoices pci (cost=0.00..73.55 rows=480 width=19)
Filter: (((from_date >= '2024-08-01'::date) OR (NOT is_draft)) AND (invoice_type <> '-1'::smallint))