QUERY PLAN
Aggregate (cost=3.20..3.21 rows=1 width=8)
-> Sort (cost=3.18..3.18 rows=1 width=357)
Sort Key: r.created_at DESC
-> HashAggregate (cost=3.16..3.17 rows=1 width=357)
Group Key: r.id
-> Hash Right Join (cost=1.27..3.15 rows=4 width=12)
Hash Cond: (eipss.erp_sales_outbound_id = r.id)
-> Seq Scan on tbl_erp_inventory_product_spents eipss (cost=0.00..1.68 rows=68 width=4)
-> Hash (cost=1.25..1.25 rows=1 width=12)
-> Seq Scan on tbl_erp_sales_outbounds r (cost=0.00..1.25 rows=1 width=12)
Filter: ((project_id = 3959) AND (status = 2))