QUERY PLAN
GroupAggregate (cost=116.84..118.28 rows=36 width=84)
Group Key: (GREATEST((CURRENT_DATE - date(eip.created_at)), 0)), gt.id
-> Sort (cost=116.84..116.93 rows=36 width=33)
Sort Key: (GREATEST((CURRENT_DATE - date(eip.created_at)), 0)), gt.id
-> Hash Left Join (cost=101.14..115.91 rows=36 width=33)
Hash Cond: (prod.product_type = gt.id)
-> Hash Join (cost=98.72..113.03 rows=36 width=25)
Hash Cond: (eip.product_id = prod.id)
-> Seq Scan on tbl_erp_inventory_products eip (cost=0.00..14.21 rows=36 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.21..72.21 rows=2121 width=8)
-> Seq Scan on tbl_products prod (cost=0.00..72.21 rows=2121 width=8)
-> Hash (cost=1.63..1.63 rows=63 width=16)
-> Seq Scan on tbl_product_types gt (cost=0.00..1.63 rows=63 width=16)