QUERY PLAN
HashAggregate (cost=186.11..188.61 rows=200 width=44)
Group Key: CASE WHEN pci.is_verify THEN 1 ELSE 0 END
-> HashAggregate (cost=178.46..181.24 rows=278 width=14)
Group Key: pci.id
-> Hash Right Join (cost=106.13..177.77 rows=278 width=11)
Hash Cond: (pcpp.purchase_invoice_id = pci.id)
-> Seq Scan on tbl_purchase_invoice_products pcpp (cost=0.00..61.13 rows=2113 width=4)
-> Hash (cost=102.65..102.65 rows=278 width=11)
-> Hash Right Join (cost=66.47..102.65 rows=278 width=11)
Hash Cond: (pip.purchase_invoice_id = pci.id)
-> Seq Scan on tbl_purchase_invoice_projects pip (cost=0.00..30.94 rows=1994 width=8)
-> Hash (cost=62.99..62.99 rows=278 width=19)
-> Seq Scan on tbl_purchase_contract_invoices pci (cost=0.00..62.99 rows=278 width=19)
Filter: (((from_date >= '2024-08-01'::date) OR (NOT is_draft)) AND (invoice_type <> '-1'::smallint))