QUERY PLAN
HashAggregate (cost=139.40..140.35 rows=63 width=80)
Group Key: gt.id
-> Hash Left Join (cost=120.87..136.71 rows=269 width=26)
Hash Cond: (prod.product_type = gt.id)
-> Hash Join (cost=118.45..133.54 rows=269 width=14)
Hash Cond: (sp.product_id = prod.id)
-> Hash Join (cost=21.65..36.04 rows=269 width=14)
Hash Cond: (eipss.erp_sales_outbound_spent_product_id = sp.id)
-> Hash Join (cost=8.04..21.73 rows=269 width=14)
Hash Cond: (eipss.erp_sales_outbound_id = t.id)
-> Seq Scan on tbl_erp_inventory_product_spents eipss (cost=0.00..12.65 rows=384 width=18)
Filter: (erp_sales_outbound_spent_product_id IS NOT NULL)
-> Hash (cost=6.70..6.70 rows=108 width=4)
-> Seq Scan on tbl_erp_sales_outbounds t (cost=0.00..6.70 rows=108 width=4)
Filter: ((created_at >= '2025-07-11 00:00:00+08'::timestamp with time zone) AND (created_at <= '2025-12-31 23:59:59+08'::timestamp with time zone) AND (status = 2))
-> Hash (cost=8.27..8.27 rows=427 width=8)
-> Seq Scan on tbl_erp_sales_outbound_spent_products sp (cost=0.00..8.27 rows=427 width=8)
-> Hash (cost=70.80..70.80 rows=2080 width=8)
-> Seq Scan on tbl_products prod (cost=0.00..70.80 rows=2080 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)