QUERY PLAN
Aggregate (cost=81.23..81.24 rows=1 width=8)
-> Group (cost=81.21..81.22 rows=1 width=364)
Group Key: esops.id
-> Sort (cost=81.21..81.21 rows=1 width=4)
Sort Key: esops.id
-> Nested Loop (cost=0.00..81.20 rows=1 width=4)
Join Filter: (esops.product_id = eips.product_id)
-> Seq Scan on tbl_erp_sales_order_products esops (cost=0.00..65.80 rows=1 width=8)
Filter: ((erp_sales_order_id = 1715) AND ((number - outbound) > '0'::numeric))
-> Seq Scan on tbl_erp_inventory_products eips (cost=0.00..14.60 rows=64 width=4)
Filter: (inventory > '0'::numeric)