QUERY PLAN
HashAggregate (cost=243.99..246.49 rows=200 width=44)
Group Key: CASE WHEN pci.is_verify THEN 1 ELSE 0 END
-> HashAggregate (cost=230.74..235.56 rows=482 width=14)
Group Key: pci.id
-> Hash Right Join (cost=125.07..229.32 rows=566 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=119.04..119.04 rows=482 width=11)
-> Hash Right Join (cost=79.65..119.04 rows=482 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=73.62..73.62 rows=482 width=19)
-> Seq Scan on tbl_purchase_contract_invoices pci (cost=0.00..73.62 rows=482 width=19)
Filter: (((from_date >= '2024-08-01'::date) OR (NOT is_draft)) AND (invoice_type <> '-1'::smallint))