QUERY PLAN
GroupAggregate (cost=128.98..130.11 rows=41 width=97)
Group Key: gs.id
-> Sort (cost=128.98..129.09 rows=41 width=46)
Sort Key: gs.id
-> Nested Loop Left Join (cost=99.02..127.89 rows=41 width=46)
-> Hash Join (cost=98.75..113.24 rows=41 width=17)
Hash Cond: (eip.product_id = prod.id)
-> Seq Scan on tbl_erp_inventory_products eip (cost=0.00..14.39 rows=41 width=17)
Filter: (((erp_purchase_inbound_id IS NOT NULL) OR (erp_purchase_gift_id IS NOT NULL) OR (erp_inventory_build_id IS NOT NULL) OR (erp_inventory_disassemble_id IS NOT NULL) OR (erp_inventory_start_id IS NOT NULL)) AND (inventory > '0'::numeric))
-> Hash (cost=72.22..72.22 rows=2122 width=8)
-> Seq Scan on tbl_products prod (cost=0.00..72.22 rows=2122 width=8)
-> Index Scan using tbl_product_series_pkey on tbl_product_series gs (cost=0.28..0.36 rows=1 width=33)
Index Cond: (id = prod.product_serie)