QUERY PLAN
Limit (cost=39.04..39.05 rows=5 width=407)
-> Sort (cost=39.04..39.05 rows=5 width=407)
Sort Key: r.wrote_date DESC
-> GroupAggregate (cost=38.68..38.93 rows=5 width=407)
Group Key: r.id
-> Sort (cost=38.68..38.70 rows=5 width=102)
Sort Key: r.id
-> Nested Loop Left Join (cost=28.47..38.63 rows=5 width=102)
-> Hash Join (cost=28.34..37.80 rows=5 width=95)
Hash Cond: (r.id = rp.erp_purchase_inbound_id)
-> Seq Scan on tbl_erp_purchase_inbounds r (cost=0.00..7.66 rows=201 width=67)
Filter: (status = ANY ('{2,5}'::integer[]))
-> Hash (cost=28.28..28.28 rows=5 width=32)
-> Hash Right Join (cost=12.56..28.28 rows=5 width=32)
Hash Cond: (eip.erp_purchase_inbound_product_id = rp.id)
-> Seq Scan on tbl_erp_inventory_products eip (cost=0.00..14.31 rows=531 width=11)
-> Hash (cost=12.50..12.50 rows=5 width=29)
-> Seq Scan on tbl_erp_purchase_inbound_products rp (cost=0.00..12.50 rows=5 width=29)
Filter: (product_id = 2261)
-> Index Scan using tbl_erp_stores_pkey on tbl_erp_stores s (cost=0.13..0.17 rows=1 width=15)
Index Cond: (eip.erp_store_id = id)