QUERY PLAN
GroupAggregate (cost=120.46..122.10 rows=41 width=88)
Group Key: (GREATEST((CURRENT_DATE - date(eip.created_at)), 0)), gc.id
-> Sort (cost=120.46..120.56 rows=41 width=37)
Sort Key: (GREATEST((CURRENT_DATE - date(eip.created_at)), 0)), gc.id
-> Hash Left Join (cost=104.34..119.36 rows=41 width=37)
Hash Cond: (prod.product_component = gc.id)
-> Hash Join (cost=98.75..113.24 rows=41 width=25)
Hash Cond: (eip.product_id = prod.id)
-> Seq Scan on tbl_erp_inventory_products eip (cost=0.00..14.39 rows=41 width=25)
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)
-> Hash (cost=3.60..3.60 rows=160 width=20)
-> Seq Scan on tbl_product_components gc (cost=0.00..3.60 rows=160 width=20)