| Aggregate (cost=678.72..678.73 rows=1 width=8) |
| -> Sort (cost=646.89..652.19 rows=2122 width=1594) |
| Sort Key: p.updated_at DESC NULLS LAST, p.id DESC |
| -> Hash Left Join (cost=429.49..529.63 rows=2122 width=1594) |
| Hash Cond: (p.id = epip.product_id) |
| Filter: ((COALESCE((sum(tbl_erp_inventory_products.inventory)), '0'::numeric) <> '0'::numeric) OR (COALESCE((sum((epop.number - COALESCE(epop.into_inventory, '0'::numeric)))), '0'::numeric) <> '0'::numeric) OR (COALESCE((sum((esop.number - COALESCE(esop.outbound, '0'::numeric)))), '0'::numeric) <> '0'::numeric) OR (COALESCE((sum((sum(COALESCE(eips.outbound, '0'::numeric))))), '0'::numeric) <> '0'::numeric) OR (COALESCE((sum((sum((epip.number - COALESCE(epip.cancel_number, '0'::numeric)))))), '0'::numeric) <> '0'::numeric)) |
| -> Hash Left Join (cost=372.70..467.24 rows=2122 width=140) |
| Hash Cond: (p.id = eip.product_id) |
| -> Hash Left Join (cost=305.45..394.42 rows=2122 width=108) |
| Hash Cond: (p.id = esop.product_id) |
| -> Hash Left Join (cost=115.52..198.91 rows=2122 width=76) |
| Hash Cond: (p.id = epop.product_id) |
| -> Hash Left Join (cost=30.13..107.93 rows=2122 width=44) |
| Hash Cond: (p.id = tbl_erp_inventory_products.product_id) |
| -> Seq Scan on tbl_products p (cost=0.00..72.22 rows=2122 width=28) |
| -> Hash (cost=25.53..25.53 rows=368 width=36) |
| -> HashAggregate (cost=17.25..21.85 rows=368 width=36) |
| Group Key: tbl_erp_inventory_products.product_id |
| -> Seq Scan on tbl_erp_inventory_products (cost=0.00..14.50 rows=550 width=7) |
| -> Hash (cost=84.82..84.82 rows=46 width=36) |
| -> HashAggregate (cost=83.78..84.36 rows=46 width=36) |
| Group Key: epop.product_id |
| -> Hash Join (cost=70.69..83.44 rows=46 width=12) |
| Hash Cond: (epop.erp_purchase_order_id = epo.id) |
| -> Seq Scan on tbl_erp_purchase_order_products epop (cost=0.00..11.60 rows=438 width=16) |
| Filter: ((number - COALESCE(into_inventory, '0'::numeric)) <> '0'::numeric) |
| -> Hash (cost=67.78..67.78 rows=233 width=4) |
| -> Seq Scan on tbl_erp_purchase_orders epo (cost=0.00..67.78 rows=233 width=4) |
| Filter: ((NOT is_done) AND (status = ANY ('{2,5}'::integer[]))) |
| -> Hash (cost=175.73..175.73 rows=1136 width=36) |
| -> HashAggregate (cost=150.17..164.37 rows=1136 width=36) |
| Group Key: esop.product_id |
| -> Hash Join (cost=73.38..139.43 rows=1432 width=11) |
| Hash Cond: (esop.erp_sales_order_id = eso.id) |
| -> Seq Scan on tbl_erp_sales_order_products esop (cost=0.00..60.25 rows=2206 width=15) |
| Filter: ((number - COALESCE(outbound, '0'::numeric)) <> '0'::numeric) |
| -> Hash (cost=59.45..59.45 rows=1114 width=4) |
| -> Seq Scan on tbl_erp_sales_orders eso (cost=0.00..59.45 rows=1114 width=4) |
| Filter: ((NOT is_done) AND (status = ANY ('{2,5}'::integer[]))) |
| -> Hash (cost=67.00..67.00 rows=19 width=36) |
| -> GroupAggregate (cost=65.77..66.81 rows=19 width=36) |
| Group Key: eip.product_id |
| -> Merge Append (cost=65.77..66.48 rows=19 width=36) |
| Sort Key: eip.product_id |
| -> GroupAggregate (cost=63.57..63.93 rows=18 width=36) |
| Group Key: eip.product_id |
| -> Sort (cost=63.57..63.62 rows=18 width=8) |
| Sort Key: eip.product_id |
| -> Nested Loop (cost=34.87..63.20 rows=18 width=8) |
| -> Hash Left Join (cost=34.60..56.28 rows=18 width=8) |
| Hash Cond: (eips.erp_inventory_disassemble_spent_id = eid.id) |
| Filter: (((eips.erp_sales_outbound_id IS NOT NULL) AND (eso_1.status = 1)) OR ((eips.erp_sales_gift_id IS NOT NULL) AND (esg.status = 1)) OR ((eips.erp_inventory_lost_id IS NOT NULL) AND (eil.status = 1)) OR ((eips.erp_inventory_build_spent_id IS NOT NULL) AND (eib.status = 1)) OR ((eips.erp_inventory_disassemble_spent_id IS NOT NULL) AND (eid.status = 1)) OR ((eips.erp_inventory_transfer_spent_id IS NOT NULL) AND (eit.status = 1))) |
| -> Hash Left Join (cost=33.49..53.65 rows=565 width=42) |
| Hash Cond: (eips.erp_inventory_transfer_spent_id = eit.id) |
| -> Hash Left Join (cost=19.66..38.31 rows=565 width=40) |
| Hash Cond: (eips.erp_inventory_build_spent_id = eib.id) |
| -> Hash Left Join (cost=18.39..35.55 rows=565 width=38) |
| Hash Cond: (eips.erp_inventory_lost_id = eil.id) |
| -> Hash Left Join (cost=17.19..32.84 rows=565 width=36) |
| Hash Cond: (eips.erp_sales_gift_id = esg.id) |
| -> Hash Left Join (cost=9.32..23.48 rows=565 width=34) |
| Hash Cond: (eips.erp_sales_outbound_id = eso_1.id) |
| -> Seq Scan on tbl_erp_inventory_product_spents eips (cost=0.00..12.65 rows=565 width=32) |
| -> Hash (cost=6.92..6.92 rows=192 width=6) |
| -> Seq Scan on tbl_erp_sales_outbounds eso_1 (cost=0.00..6.92 rows=192 width=6) |
| -> Hash (cost=5.72..5.72 rows=172 width=6) |
| -> Seq Scan on tbl_erp_sales_gifts esg (cost=0.00..5.72 rows=172 width=6) |
| -> Hash (cost=1.09..1.09 rows=9 width=6) |
| -> Seq Scan on tbl_erp_inventory_losts eil (cost=0.00..1.09 rows=9 width=6) |
| -> Hash (cost=1.12..1.12 rows=12 width=6) |
| -> Seq Scan on tbl_erp_inventory_builds eib (cost=0.00..1.12 rows=12 width=6) |
| -> Hash (cost=11.70..11.70 rows=170 width=6) |
| -> Seq Scan on tbl_erp_inventory_transfers eit (cost=0.00..11.70 rows=170 width=6) |
| -> Hash (cost=1.05..1.05 rows=5 width=6) |
| -> Seq Scan on tbl_erp_inventory_disassembles eid (cost=0.00..1.05 rows=5 width=6) |
| -> Index Scan using tbl_erp_inventory_products_pkey on tbl_erp_inventory_products eip (cost=0.28..0.38 rows=1 width=8) |
| Index Cond: (id = eips.erp_inventory_product_id) |
| -> GroupAggregate (cost=2.18..2.21 rows=1 width=36) |
| Group Key: eprp.product_id |
| -> Sort (cost=2.18..2.19 rows=1 width=9) |
| Sort Key: eprp.product_id |
| -> Hash Join (cost=1.09..2.17 rows=1 width=9) |
| Hash Cond: (eprp.erp_purchase_return_id = epr.id) |
| -> Seq Scan on tbl_erp_purchase_return_products eprp (cost=0.00..1.06 rows=6 width=13) |
| -> Hash (cost=1.07..1.07 rows=1 width=4) |
| -> Seq Scan on tbl_erp_purchase_returns epr (cost=0.00..1.07 rows=1 width=4) |
| Filter: (status = 1) |
| -> Hash (cost=56.61..56.61 rows=15 width=36) |
| -> GroupAggregate (cost=55.48..56.46 rows=15 width=36) |
| Group Key: epip.product_id |
| -> Merge Append (cost=55.48..56.20 rows=15 width=36) |
| Sort Key: epip.product_id |
| -> GroupAggregate (cost=19.34..19.38 rows=2 width=36) |
| Group Key: epip.product_id |
| -> Sort (cost=19.34..19.34 rows=2 width=12) |
| Sort Key: epip.product_id |
| -> Hash Join (cost=7.74..19.33 rows=2 width=12) |
| Hash Cond: (epip.erp_purchase_inbound_id = epi.id) |
| -> Seq Scan on tbl_erp_purchase_inbound_products epip (cost=0.00..10.41 rows=441 width=16) |
| -> Hash (cost=7.72..7.72 rows=1 width=4) |
| -> Seq Scan on tbl_erp_purchase_inbounds epi (cost=0.00..7.72 rows=1 width=4) |
| Filter: (status = 1) |
| -> GroupAggregate (cost=2.81..2.86 rows=2 width=36) |
| Group Key: epgp.product_id |
| -> Sort (cost=2.81..2.82 rows=2 width=41) |
| Sort Key: epgp.product_id |
| -> Hash Join (cost=1.29..2.80 rows=2 width=41) |
| Hash Cond: (epgp.erp_purchase_gift_id = epg.id) |
| -> Seq Scan on tbl_erp_purchase_gift_products epgp (cost=0.00..1.39 rows=39 width=45) |
| -> Hash (cost=1.27..1.27 rows=1 width=4) |
| -> Seq Scan on tbl_erp_purchase_gifts epg (cost=0.00..1.27 rows=1 width=4) |
| Filter: (status = 1) |
| -> GroupAggregate (cost=2.34..2.36 rows=1 width=36) |
| Group Key: eiop.product_id |
| -> Sort (cost=2.34..2.34 rows=1 width=41) |
| Sort Key: eiop.product_id |
| -> Hash Join (cost=1.14..2.33 rows=1 width=41) |
| Hash Cond: (eiop.erp_inventory_overflow_id = eio.id) |
| -> Seq Scan on tbl_erp_inventory_overflow_products eiop (cost=0.00..1.14 rows=14 width=45) |
| -> Hash (cost=1.12..1.12 rows=1 width=4) |
| -> Seq Scan on tbl_erp_inventory_overflows eio (cost=0.00..1.12 rows=1 width=4) |
| Filter: (status = 1) |
| -> GroupAggregate (cost=2.45..2.57 rows=6 width=36) |
| Group Key: eibp.product_id |
| -> Sort (cost=2.45..2.47 rows=6 width=9) |
| Sort Key: eibp.product_id |
| -> Hash Join (cost=1.22..2.38 rows=6 width=9) |
| Hash Cond: (eibp.erp_inventory_build_id = eib_1.id) |
| -> Seq Scan on tbl_erp_inventory_build_products eibp (cost=0.00..1.11 rows=11 width=13) |
| -> Hash (cost=1.15..1.15 rows=6 width=4) |
| -> Seq Scan on tbl_erp_inventory_builds eib_1 (cost=0.00..1.15 rows=6 width=4) |
| Filter: (status = 1) |
| -> GroupAggregate (cost=2.21..2.25 rows=2 width=36) |
| Group Key: eidp.product_id |
| -> Sort (cost=2.21..2.21 rows=2 width=9) |
| Sort Key: eidp.product_id |
| -> Hash Join (cost=1.07..2.20 rows=2 width=9) |
| Hash Cond: (eidp.erp_inventory_disassemble_id = eid_1.id) |
| -> Seq Scan on tbl_erp_inventory_disassemble_products eidp (cost=0.00..1.08 rows=8 width=13) |
| -> Hash (cost=1.06..1.06 rows=1 width=4) |
| -> Seq Scan on tbl_erp_inventory_disassembles eid_1 (cost=0.00..1.06 rows=1 width=4) |
| Filter: (status = 1) |
| -> GroupAggregate (cost=24.05..24.07 rows=1 width=36) |
| Group Key: eitp.product_id |
| -> Sort (cost=24.05..24.06 rows=1 width=36) |
| Sort Key: eitp.product_id |
| -> Hash Join (cost=12.14..24.04 rows=1 width=36) |
| Hash Cond: (eitp.erp_inventory_transfer_id = eit_1.id) |
| -> Seq Scan on tbl_erp_inventory_transfer_products eitp (cost=0.00..11.50 rows=150 width=40) |
| -> Hash (cost=12.12..12.12 rows=1 width=4) |
| -> Seq Scan on tbl_erp_inventory_transfers eit_1 (cost=0.00..12.12 rows=1 width=4) |
| Filter: (status = 1) |
| -> GroupAggregate (cost=2.18..2.21 rows=1 width=36) |
| Group Key: esrp.product_id |
| -> Sort (cost=2.18..2.19 rows=1 width=9) |
| Sort Key: esrp.product_id |
| -> Hash Join (cost=1.09..2.17 rows=1 width=9) |
| Hash Cond: (esrp.erp_sales_return_id = esr.id) |
| -> Seq Scan on tbl_erp_sales_return_products esrp (cost=0.00..1.06 rows=6 width=13) |
| -> Hash (cost=1.07..1.07 rows=1 width=4) |
| -> Seq Scan on tbl_erp_sales_returns esr (cost=0.00..1.07 rows=1 width=4) |
| Filter: (status = 1) |