QUERY PLAN
Sort (cost=68.99..69.09 rows=42 width=127)
Sort Key: eip.created_at DESC
-> HashAggregate (cost=67.43..67.85 rows=42 width=127)
Group Key: eip.id
-> Hash Right Join (cost=32.29..66.46 rows=388 width=127)
Hash Cond: (eios.id = eip.erp_inventory_overflow_id)
-> Hash Right Join (cost=1.18..34.64 rows=74 width=4)
Hash Cond: (eiops.erp_inventory_overflow_id = eios.id)
-> Seq Scan on tbl_erp_inventory_overflow_projects eiops (cost=0.00..28.50 rows=1850 width=4)
-> Hash (cost=1.08..1.08 rows=8 width=4)
-> Seq Scan on tbl_erp_inventory_overflows eios (cost=0.00..1.08 rows=8 width=4)
-> Hash (cost=30.59..30.59 rows=42 width=127)
-> Hash Right Join (cost=25.62..30.59 rows=42 width=127)
Hash Cond: (epips.erp_purchase_inbound_id = epis.id)
-> Seq Scan on tbl_erp_purchase_inbound_projects epips (cost=0.00..3.89 rows=189 width=4)
-> Hash (cost=25.09..25.09 rows=42 width=131)
-> Hash Left Join (cost=10.77..25.09 rows=42 width=131)
Hash Cond: (eip.erp_purchase_inbound_id = epis.id)
-> Seq Scan on tbl_erp_inventory_products eip (cost=0.00..14.21 rows=42 width=127)
Filter: ((NOT is_build) AND (inventory > '0'::numeric))
-> Hash (cost=8.12..8.12 rows=212 width=4)
-> Seq Scan on tbl_erp_purchase_inbounds epis (cost=0.00..8.12 rows=212 width=4)